Sometimes I accidently put from the wrong register and end up hitting u to undo, but then I have to reselect the text that I was trying to replace. Is there an easy way to either reapply the put from the correct register or undo and restore the text that was previously selected?
put the normal register are not modified apart from the
* if you are using
clipboard unnamed setting) register that are replaced by the content that you override.
To avoid that behavior some use the mapping:
xnoremap p pgvy
It restores the content of the
" to the value that has just been pasted.
A more advance version of this mapping does it only if you have used the
" register to paste:
xnoremap <expr> p v:register=='"'?'pgvy':'p'