How to delete (not cut) in Vim

copy/pastevim

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.

Best Answer

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

When you enter the line back with the p command you are pasting the contents of the (volatile) default register "", which has been overwritten by dd. But you still can paste from the (non volatile) yank register "0, which won't be overwritten by the delete command dd.

So these are the commands you want to use as per your example:

yy
dd
"0p