问题
I was sure I knew how to do it but I tried on different machines and it seems I don't know.
1 COPY THIS
2
3
4 HERE
5 HERE
So that it becomes
1 COPY THIS
2
3
4 COPY THIS
5 COPY THIS
What I tried: Shift-V on line 1 to copy line in visual mode, then go to line 4 visual mode vertical selection on lines 4 and 5. Now p to paste.
I was expecting to paste to both lines.
What happens: It paste to line 4 and line 5 gets deleted.
May I ask a friendly help here?
回答1:
You must paste twice: 2p
instead of p
also, if you only want to copy one line whole, you can skip the visual line and just use yy
and to eradicate the visualmode altogether do this:
:0
yy
:4
2dd
2"0p
which will do:
GOTO line 0
copy the current line
GOTO line 4
delete the following two lines (*)
twice: paste line from register 0
(*) note that the deletion overrides the entry in the default register.
See also this Q&A on Unix.SE
来源:https://stackoverflow.com/questions/52016333/vim-copy-one-line-and-paste-it-to-multiple-lines