Monday, October 7, 2013

Re: yanking non-contiguous lines?

On 2013-10-07 14:39, Chris Lott wrote:
> Assuming Vim without plugins like YankRing or the like, what is the
> fastest way to copy non-contiguous lines to another place in the
> document, such as a document:
>
> AAA
> BBB
> CCC
> DDD
>
> That I want to become
>
> AAA
> BBB
> CCC
> DDD
>
> AAA
> CCC
> DDD

How do you identify those non-contiguous lines? By a regexp?

You can do something like

:g/^[ACD]/t$

which uses the :t (a.k.a. ":copy") to copy the lines matching the
pattern to a destination (in this case, "$" is the end of the file,
but could just as easily be a mark you dropped previously with
"g:/^[ACD]/t 'a"

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: