如何在Vim中删除(不剪切)? [英] How to delete (not cut) in Vim?
问题描述
如何删除一行而不将其放入默认缓冲区?
How can I delete a line without putting it into my default buffer?
示例:
line that will be copied.
line that I want to be substitued with the previous one.
我要做什么:
yy
dd
p
但是Vim用删除(剪切)的字符串替换最近复制的字符串。我知道我可以使用 1yy
, dd
然后是 1p
,但是我总是忘了将复制的字符串放在缓冲区中,然后我需要先粘贴我的内容(将要复制的行),然后删除想要的内容(我要替换为前一行的行)一个。)
But Vim replaces the recent copied string with the deleted (cutted) one. I know that I can use buffers like, "1yy
, dd
then "1p
, but I always forget to put the copied string in a buffer then I need to paste my contents first (line that will be copied) and then delete what I want (line that I want to be substituted with the previous one.)
我该如何在不复制的情况下真正删除Vi(m)中的文本?
How can I really delete a text in Vi(m) without copying it?
另一个相关的问题是如何在插入模式下转发删除单词?我想要类似 Ctrl + w 的东西。
Another related question is how I can forward delete a word in insert mode? I want something similar to Ctrl+w.
推荐答案
黑洞寄存器, _
真正删除某些内容: _ d
。
使用 _ dP
粘贴某些内容并使其可用于进一步粘贴。
Use the "black hole register", "_
to really delete something: "_d
.
Use "_dP
to paste something and keep it available for further pasting.
对于第二个问题,您可以使用< C-o> dw
。< C-o>
用于执行普通命令,而不会留下 insert 模式。
For the second question, you could use <C-o>dw
. <C-o>
is used to execute a normal command without leaving the insert mode.
当然,您可以设置自己的映射来保存键入内容。
You can setup your own mappings to save typing, of course. I have these:
nnoremap <leader>d "_d
xnoremap <leader>d "_d
xnoremap <leader>p "_dP
这篇关于如何在Vim中删除(不剪切)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!