Monday, October 7, 2013

Re: yanking non-contiguous lines?

On 14:39 Mon 07 Oct , 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
>
> Thanks!
>
> c
> --
> Chris Lott <chris@chrislott.org>

Here is one possible solution:
:g/\%1l\|\%3l\|\%4l/t$
assuming that AAA is on the line 1 and we are coping thing to the end
of file. As you can see the g command is not very handy to do that.
Another way is to go to AAA and copy to a register, let say 'a' (with
normal command "aY) and then go to the next line and copy it with "AY
(which means append to the register a). You can also use visual
selection if it makes it easier. And then paste from the register a.

Best regards,
Marcin

--
--
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: