How to delete (not cut) in Vim? Ask Question

How to delete (not cut) in Vim? Ask Question

How can I delete a line without putting it into my default buffer?

Example:

line that will be copied.

line that I want to be substitued with the previous one.

What I'm trying to do:

yy
dd
p

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.)

How can I really delete a text in Vi(m) without copying it?

Another related question is how I can forward delete a word in insert mode? I want something similar to Ctrl+w.

ベストアンサー1

The black hole register "_ will do the trick, but there is a better solution:

コマンドで行を back 入力すると、によって上書きされた(揮発性の)デフォルト レジスタpの内容を貼り付けます。ただし、削除コマンドによって上書きされない(非揮発性の)ヤンク レジスタからは貼り付けることができます。 ""dd "0dd

したがって、例に従って使用するコマンドは次のとおりです。

yy
dd
"0p

おすすめ記事