How to paste over without overwriting register

Use the following:

xnoremap p pgvy

this will reselect and re-yank any text that is pasted in visual mode.

Edit: in order this to work with "xp you can do:

xnoremap p pgv"@=v:register.'y'<cr>

v:register expands to the last register name used in a normal mode command.

Leave a Comment