aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-29 23:29:37 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-29 23:29:37 +1300
commita47dc5d42d62609547993d1c4eca1d9e8ba2ad19 (patch)
tree82eb41a9f545ca2f425835da52872db0d04539c4
parentMerge branch 'release/v1.0.0' (diff)
parentBump VERSION (diff)
downloadvim-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--VERSION2
-rw-r--r--autoload/replace_operator.vim18
2 files changed, 13 insertions, 7 deletions
diff --git a/VERSION b/VERSION
index 3eefcb9..7dea76e 100644
--- a/VERSION
+++ b/VERSION
@@ -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