diff options
Diffstat (limited to 'autoload/replace_operator.vim')
-rw-r--r-- | autoload/replace_operator.vim | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/autoload/replace_operator.vim b/autoload/replace_operator.vim index a48a04d..ff442b6 100644 --- a/autoload/replace_operator.vim +++ b/autoload/replace_operator.vim @@ -20,17 +20,23 @@ function! replace_operator#Operatorfunc(type) abort " Ensure that we include end-of-line and final characters in selections set selection=inclusive - " Select or re-select text, depending on how we were invoked + " Build normal mode keystrokes to select the operated text in visual mode if a:type ==# 'line' - normal! '[V'] + let l:select = '''[V'']' elseif a:type ==# 'block' - execute "normal! `[\<C-V>`]" + let l:select = "`[\<C-V>`]" else - normal! `[v`] + let l:select = '`[v`]' endif - " Re-select the text, and replace it with the contents of the register - execute 'normal! "'.l:register.'p' + " Build normal mode keystrokes to paste from the selected register; only add + " a register prefix if it's not the default unnamed register, because Vim + " before 7.4 gets ""p wrong in visual mode + let l:paste = 'p' + if l:register !=# '"' + let l:paste = '"'.l:register.l:paste + endif + silent execute 'normal! '.l:select.l:paste " Restore contents of the unnamed register and the previous values of the " 'clipboard' and 'selection' options |