vimcopypaste

Paste multiple times


What is the best way replace multiple lines with the contents of the clipboard?

The problem I'm having is when I yank a line and paste it over another line the "yank" is replaced with the line I just replace. Now, if I want to replace another line with the same line I have to go back up and yank it again.

There's got to be a better way to do this.


Solution

  • I have this in my .vimrc:

    xnoremap p pgvy
    

    (note: this will work only with the default register, but this mapping is easy to remember). Writing a more elaborate version would be possible.

    Also, you can press P (Shift+p) instead of p to paste over the selection without overwriting the clipboard.