Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy multiple times before pasting all of the contents in vim

In vim, would there be a way to copy multiple times, accumulate each of them into the clipboard, and then later paste all of them at once where each contents are separated by newline?

like image 468
villybyun Avatar asked Oct 25 '25 23:10

villybyun


2 Answers

Use uppercase registers to append. For example, let's clear and yank a line to register "a, append a line, append another line, then paste:

"ayy
"Ayy
"Ayy
"ap

Flag > in cpoptions inserts a line break before the appended text.

like image 122
phd Avatar answered Oct 27 '25 23:10

phd


If all those lines share a pattern you can :help :copy (or its shortest alternative :help :t) them all at once with:

:g/pattern/t<line number>
like image 23
romainl Avatar answered Oct 28 '25 01:10

romainl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!