aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/searchop.vim
blob: ecfe2a157336d6622a64aafb751b957797115c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
nnoremap <silent> z/ :set opfunc=Search<CR>g@
vnoremap <silent> z/ :<C-u>call Search(visualmode(), 1)<CR>


function! 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('/', @/)

	call feedkeys('n', 't')

	let @@ = user_unnamed_register
endfunction