How to paste over without overwriting register

后端 未结 10 2579
粉色の甜心
粉色の甜心 2020-11-28 02:41

Does anyone know of a way to paste over a visually selected area without having the selection placed in the default register?

I know I can solve the problem by alway

10条回答
  •  猫巷女王i
    2020-11-28 03:14

    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'
    

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

提交回复
热议问题