aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugin/searchop.vim19
1 files changed, 16 insertions, 3 deletions
diff --git a/plugin/searchop.vim b/plugin/searchop.vim
index ecfe2a1..a0b9835 100644
--- a/plugin/searchop.vim
+++ b/plugin/searchop.vim
@@ -1,5 +1,8 @@
-nnoremap <silent> z/ :set opfunc=Search<CR>g@
-vnoremap <silent> z/ :<C-u>call Search(visualmode(), 1)<CR>
+nnoremap <silent> z/ :set opfunc=SearchForward<CR>g@
+vnoremap <silent> z/ :<C-u>call SearchForward(visualmode(), 1)<CR>
+
+nnoremap <silent> z# :set opfunc=SearchBackward<CR>g@
+vnoremap <silent> z# :<C-u>call SearchBackward(visualmode(), 1)<CR>
function! Search(type, ...)
@@ -16,7 +19,17 @@ function! Search(type, ...)
let @/ = substitute(escape(@@, '\'), '\n', '\\n', 'g')
call histadd('/', @/)
+ let @@ = user_unnamed_register
+endfunction
+
+function! SearchForward(type, ...)
+ call call('Search', [a:type] + a:000)
+
call feedkeys('n', 't')
+endfunction
- let @@ = user_unnamed_register
+function! SearchBackward(type, ...)
+ call call('Search', [a:type] + a:000)
+
+ call feedkeys('N', 't')
endfunction