vi中如何从当前位置复制到行尾
我在 Windows 中使用 gvim。如何在 vi 中将文本从当前位置复制到行尾并将其粘贴到在 vi 中打开的另一个文件中?
I use gvim in windows. How do I copy text from the current position to the end of the line in vi and paste it in another file opened in vi?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
移动到行尾的普通模式命令是
$
。您可以使用
y$
复制到行尾,然后使用p
粘贴。要在不同实例之间复制/粘贴,您可以通过选择
*
寄存器来使用系统剪贴板,因此命令变为"*y$
用于复制,"* p
用于粘贴。$
移动到换行符$
y$
复制到换行符y ,$
"*y$
选择剪贴板寄存器 yank-to-linebreak",*,y,$
"*p
选择剪贴板-注册粘贴",*,p
检查
:h 寄存器
了解更多信息。The normal-mode command to move to the end of the line is
$
.You can copy to the end of the line with
y$
and paste withp
.To copy/paste between different instances, you can use the system clipboard by selecting the
*
register, so the commands become"*y$
for copying and"*p
for pasting.$
move-to-linebreak$
y$
yank-to-linebreaky,$
"*y$
select clipboard-register yank-to-linebreak",*,y,$
"*p
select clipboard-register paste",*,p
Check
:h registers
for more information.如果您不想在复制时包含换行符,可以使用
yg_
。 (或者在您的情况下,"*yg_
)基本上,只需认识到
$
和g_
运动方面存在差异。这对我有帮助无数次。If you don't want to include the line break with the yank, you can use
yg_
. (Or in your case,"*yg_
)Basically, just recognize there's a difference between
$
andg_
movement-wise. It's helped me on numerous occasions.将此行添加到您的 .vimrc
更多内容请参见 我的 vimrc。
Add this line to your .vimrc
More at my vimrc.
另一种解决方案:
Dp
并用p
粘贴。事实上,这首先删除到行尾,然后将其重新粘贴到同一位置。使用p
将其粘贴到其他位置。A different solution:
Dp
and paste it withp
. In fact this first deletes to the end of line and re-pastes it at the same location. Paste it somewhere else withp
.