How to paste over without overwriting register
I don't like the default vim behavior of copying all text deleted with d
, D
, c
, or C
into the default register.
I've gotten around it by mapping d
to "_d
, c
to "_c
, and so on.
From my .vimrc:
"These are to cancel the default behavior of d, D, c, C
" to put the text they delete in the default register.
" Note that this means e.g. "ad won't copy the text into
" register a anymore. You have to explicitly yank it.
nnoremap d "_d
vnoremap d "_d
nnoremap D "_D
vnoremap D "_D
nnoremap c "_c
vnoremap c "_c
nnoremap C "_C
vnoremap C "_C
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.