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?



2 Answers 2


One way could be to overwrite that line instead of deleting it:

  1. Copy the content
  2. Move to line to be deleted and press V to select the whole line (or use v and manually select whichever region you need)
  3. Press p to paste.
  • This is also a good solution. The other question, which this is a duplicate of, has nice answers too.
    – user473
    Feb 11, 2015 at 20:31
  • 1
    Yes, and mine doesn't quite fit there, that's why I answered here. :)
    – muru
    Feb 11, 2015 at 20:31
  • Thanks. But I think you should add this answer to there too, because this question will be closed as a duplicate most probably. I think yours is a good alternative solution.
    – user473
    Feb 11, 2015 at 20:40
  • 1
    @purplehuman Closed questions will remain on the site, and can still be voted & commented on. The only thing you can't do is add new answers. Feb 11, 2015 at 20:51
  • @Carpetsmoker Ah, okay. Good to know. Thanks.
    – user473
    Feb 11, 2015 at 20:53

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.

  • Thanks. Unfortunately I'm out of votes for 2 hours. :) I'll be back.
    – user473
    Feb 11, 2015 at 21:46
  • All already listed in vi.stackexchange.com/a/125/205.
    – muru
    Feb 11, 2015 at 22:12
  • Yeah, that site and its questions are a joke.
    – romainl
    Feb 11, 2015 at 22:17