Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
created June 6, 2009 · complexity basic · version 7.0
The visual mode put command (:help v_p) can be used to paste previously copied text onto a visual selection, that is, to replace selected test with previously yanked text.
However, the default behavior of this paste command has a side effect: It also copies the text that is being replaced. As explained in :help v_p:
- Implementation detail: it actually works by first putting the register after the selection and then deleting the selection.
So, it is the same as pressing dP after visually selecting the text to replace.
A quick solution to change the default behaviour of the visual mode command is to just remap with:
vnoremap p "_dP
Here we simply discard the deleted text by storing it into the black hole register.