On Thu, Jul 23, 2020 at 08:18:23PM -0500, Tim Chase wrote:
> The ex "y" command yanks and can take an optional register to yank
> to.  By default, your
> 
>   :g/^-/normal yy
> 
> (using the normal-mode) would be the same as ex-mode "y" command:
> 
>   :g/^-/y
> 
> which yanks, overwriting the default " register.
> 
> If you specify a register, vi/vim will yank into that register
> instead.  In normal mode, you'd prefix your command with the
> register-name:
> 
>   "ayy
> 
> to yank the current line into register "a".
> 
> The trick is that *uppercase* registers write to the same register as
> their lowercase variants, but they *append* instead of *overwrite*.
> 
>   :help quote_alpha
> 
> So by using
> 
>   :g/^-/y A
> 
> (or as a jump to normal mode
> 
>   :g/^-/normal "Ayy
> 
> would do the same thing) each line matching your pattern gets yanked
> *and appended* to register "a", gathering them all up so you can then
> use the "a" register either to paste or transfer the results to the
> system clipboard (the "+" register) via a `:let` command
> 
>   :let @+=@a
> 
> Hopefully that makes more sense of it?
> 
Thanks a lot for your help.
-- 
Manas
CSAM Undergraduate | 2022
IIIT-Delhi, India
-- 
-- 
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200724110921.bxoxtn3mzsdfr4kx%40nitro-5.
No comments:
Post a Comment