I frequently use the :g command with m0 or m$ to move the matching text to the beginning or end of the current buffer.

How can I move the matching lines to a new buffer/tab?

I don't know of a one-pass way to do this easily, but you can either of the following which I've used in the past to do this:

1) do the above, and then delete the gathered lines and paste them elsewhere or

2)

:let @a='' | g/pattern/d A

go to the other buffer/tab/window and

        "aP

to dump the contents that have been deleted to the "a" register.

I don't know if it would choke vim to do something like

:g/regex/d| wincmd p | put | wincmd p

(which might need to have the "wincmd p" changed to

        exec "wincmd p"

if there are problems with the pipe)

Just a few ideas.

-tim




Reply via email to