When I yank a line with y
and paste it with p
, it's okay. But when I need to delete a line with dd
before pasting my yank buffer changes. Can I still paste my yanked line? Is there a way to do that?
Thanks.
One way could be to overwrite that line instead of deleting it:
V
to select the whole line (or use v
and manually select whichever region you need)p
to paste.Yanked text is kept in register "0
until the next explicit yank. This means that you can cut as many lines as you want, "0p
will still put the same text.
Another option is to use the black hole register, "_
to actually delete text instead of the default "cut" behavior. This will preserve the unnamed register and let you p
from it as much as you want.
See :help registers
.