Force VIM to stop overwriting your default buffer when pasting

I use VIM all the time for development, one thing that always bugs me is when I yank a chunk of code into my default buffer, and then paste if over something else, VIM will take whatever was pasted over and overwrite my default buffer with it. So the next time I try to paste, it will paste the previously pasted over text instead of the original stuff I yanked. Stick the following line into your .vimrc file to fix this...

xnoremap  P v:register=='"'?'pgvy':'p'

It remaps "P" to paste and then pull back into your default buffer the same stuff you pasted so it's there to paste again. Very handy for me.

BTW you can always check out my dotfiles for varios parts of my unix environment in my Github Unix Environment Repo

Post A Twitter Response To This Blog Post

To: @mattccrampton