Suppose you have 5 lines in current buffer among others. You yank them using 5Y, make a new buffer with e.g. tabe, and try to paste these 5 lines so that they are the only thing the new buffer would consist of. Yet if you use p, you get an empty line before the lines pasted. If you use P, you get an empty line after them.

Is there any way to paste without introducing extra lines and without doing fix-ups like k"_dd after p?

1 Answer 1


Yes there is! I do this all the time:




If you paste in visual mode, the visual selection is replaced with the contents of the register, so you end up replacing an empty line with what you wanted, and get no extra line. The only downside to this approach is that it will empty out your register, so you'll have to re-yank if you want to paste it several times.

  • 2
    Or yank to a dedicated register (IIRC its only the " register thats overwritten in a visual paste, right? Or is it the register pasted from?)
    – D. Ben Knoble
    Commented May 1, 2019 at 14:51
  • 1
    @D.BenKnoble Oh, that's a good point. It's just the " register, not the one pasted from.
    – DJMcMayhem
    Commented May 1, 2019 at 14:55
  • Hmm, doesn't empty out mine. I must have changed something in my paste settings...
    – Ruslan
    Commented May 1, 2019 at 15:17
  • 1
    @Ruslan technically the contents of the " register should be replaced by the selected text. Ive seen people create visual-mode mappings to avoid this though
    – D. Ben Knoble
    Commented May 1, 2019 at 17:33
  • 1
    You could still paste the prev y with <C-r>0 p I think - as the zero register is reserved for yank, and isn't overridden by a delete
    – Drenai
    Commented Dec 27, 2020 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.