问题
I know I can yy
on line 1 and then visual select lines 4 and 5 2p
(Vim copy one line and paste it to multiple lines).
1 COPY THIS
2
3
4 HERE
5 HERE
So I get:
1 COPY THIS
2
3
4 COPY THIS
5 COPY THIS
But instead, let's say I would like just COPY. If I visual block select COPY and then 2p
on lines 4 and 5 visual selected
1 COPY THIS
2
3
4 COPYCOPY
5
How do I paste 1x at each line? Like:
1 COPY THIS
2
3
4 COPY
5 COPY
回答1:
You can modify the register "
(unnamed) to contain a newline, but at this point its most likely easier to create a new line, paste your content in it and dd
it again.
v
l (or other moving chars to mark the area you want)
y
:let @" = @" . "\n"
2p
For further ideas see also this thread.
来源:https://stackoverflow.com/questions/52017570/vim-copy-a-block-and-paste-it-to-multiple-lines