我在窗口中使用 gvim。如何将文本从 vi 中的当前位置复制到行尾,并将其粘贴到在 vi 中打开的另一个文件中?
The normal-mode command to move to the end of the line is $.
$
您可以用 y$复制到该行的末尾,然后用 p粘贴。
y$
p
要在不同的实例之间复制/粘贴,您可以通过选择 *寄存器来使用系统剪贴板,这样命令就变成了用于复制的 "*y$和用于粘贴的 "*p。
*
"*y$
"*p
$移动到换行突破
y$猛攻
y,$
"*y$ select clipboard-register yank-to-linebreak
",*,y,$
"*p select clipboard-register paste
",*,p
有关更多信息,请查看 :h registers。
:h registers
如果您不想包含换行符,可以使用 yg_。(或者在你的情况下,"*yg_)
yg_
"*yg_
Basically, just recognize there's a difference between $ and g_ movement-wise. It's helped me on numerous occasions.
g_
Add this line to your .vimrc
" Make Y yank till end of line nnoremap Y y$
my vimrc台更多。
一个不同的解决方案: Dp和粘贴它与 p。事实上,这首先删除到行的末尾并在同一位置重新粘贴它。粘贴到其他地方与 p。
Dp