For example if I copy several lines of text and open a brand new file. If I paste with p, then I get an empty line above the pasted text, and if I paste with P, I get an empty line below the pasted text.

How can I paste and remove/replace/delete the current line?


Select the current line in visual mode before pasting: Vp.

  • Makes sense. I was hoping there was something more simple, without visual mode. – aharris88 Feb 5 '15 at 18:44
  • @aharris88 I did a little research on this and I can't find a simpler way to do it. I'd love to be proven wrong, though! – Undo Feb 5 '15 at 18:46
  • 1
    You can always rebind this key combination to something else (like noremap p Vp). – Martin Tournoij Feb 5 '15 at 18:57
  • Yeah, but p is too useful to overwrite. Vp is fine. I don't need it that often. – aharris88 Feb 5 '15 at 19:06

As you have mentioned that you want to paste the text in a new file. This would work once you have the text selected

:'<,'>w new_filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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