diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-29 23:29:37 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-29 23:29:37 +1300 |
commit | a47dc5d42d62609547993d1c4eca1d9e8ba2ad19 (patch) | |
tree | 82eb41a9f545ca2f425835da52872db0d04539c4 | |
parent | Merge branch 'release/v1.0.0' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-replace-operator-a47dc5d42d62609547993d1c4eca1d9e8ba2ad19.tar.gz vim-replace-operator-a47dc5d42d62609547993d1c4eca1d9e8ba2ad19.zip |
Merge branch 'hotfix/v1.0.1'v1.0.1
* hotfix/v1.0.1:
Fix text replacement for Vim 7.1 through 7.3
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/replace_operator.vim | 18 |
2 files changed, 13 insertions, 7 deletions
@@ -1 +1 @@ -1.0.0 +1.0.1 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 |