且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Vim复制一行并将其粘贴到多行

更新时间:2022-02-27 22:12:03

您必须粘贴两次:2p而不是p

You must paste twice: 2p instead of p

此外,如果您只想整行复制一条线,则可以跳过视线并仅使用yy

also, if you only want to copy one line whole, you can skip the visual line and just use yy

并完全消除视觉模式:

:0
yy
:4
2dd
2"0p

这将做到:

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.

另请参见在Unix上的此问题与解答. SE