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?
Asked
Active
Viewed 534 times
3 Answers
7
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.

phd
- 82,685
- 13
- 120
- 165
5
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>

romainl
- 186,200
- 21
- 280
- 313
-
This pastes in inverse order. I have a list that goes 1-40, and the paste goes 40-1. How could one paste in order? – nilon Aug 09 '19 at 17:57
1
I have this line in my .vimrc
nnoremap yY :let @"=@".getline('.')."\n"<CR>
Pressing yY
appends the line under the cursor to the unnamed register.
Use it like this:
First press yy
to yank line under cursor.
Then press yY
on several other lines.
Finally press p
to put all these line somewhere.

XPlatformer
- 1,148
- 8
- 18