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.
Use the "black hole register", "_
to really delete something: "_d
.
Use "_dP
to paste something and keep it available for further pasting.
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