From 682926ad56ff1ce2f6498eed1cefa021dbe04839 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 5 Feb 2020 23:02:27 +0100 Subject: Move functions to autoload --- autoload/searchop.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 autoload/searchop.vim (limited to 'autoload/searchop.vim') diff --git a/autoload/searchop.vim b/autoload/searchop.vim new file mode 100644 index 0000000..6912787 --- /dev/null +++ b/autoload/searchop.vim @@ -0,0 +1,28 @@ +function! s:Search(type, ...) + let user_unnamed_register = @@ + + if a:0 + silent execute "normal! gvy" + elseif a:type == 'line' + silent execute "normal! '[V']y" + else + silent execute "normal! `[v`]y" + endif + + let @/ = substitute(escape(@@, '\'), '\n', '\\n', 'g') + call histadd('/', @/) + + let @@ = user_unnamed_register +endfunction + +function! searchop#SearchForward(type, ...) + call call('s:Search', [a:type] + a:000) + + call feedkeys('n', 't') +endfunction + +function! searchop#SearchBackward(type, ...) + call call('s:Search', [a:type] + a:000) + + call feedkeys('N', 't') +endfunction -- cgit v1.2.3