“{register} p将不会像你所描述的那样工作,它会将选择替换为寄存器的内容,你将会做以下事情:
- " I haven't found how to hide this function (yet)
- function! RestoreRegister()
- let @" = s:restore_reg
- return ''
- endfunction
- function! s:Repl()
- let s:restore_reg = @"
- return "p@=RestoreRegister()\<cr>"
- endfunction
- " NB: this supports "rp that replaces the selection by the contents of @r
- vnoremap <silent> <expr> p <sid>Repl()
只要你不使用一个非零的vmap到p的插件,并期望一个寄存器被覆盖,这应该是好的。