nvim: plugin/visual-star-search: Set mark when doing backward search

While at it, drop calling set hlsearch for * and g* as hlsearch is
enabled by default and does not seem to be required.
This commit is contained in:
Sanchayan Maity 2022-05-16 18:25:12 +05:30
parent 68581433e3
commit d4f81fe865

View file

@ -15,9 +15,13 @@ func! s:get_visual_selection_searchpattern() abort
endf endf
" Read last visual-selection into command line " Read last visual-selection into command line
cnoremap <c-r><c-v> <c-r>=join(<sid>get_visual_selection_list(), " ")<cr> cnoremap <c-r><c-v> <c-r>=join(<sid>get_visual_selection_list(), " ")<CR>
inoremap <c-r><c-v> <c-r>=join(<sid>get_visual_selection_list(), " ")<cr> inoremap <c-r><c-v> <c-r>=join(<sid>get_visual_selection_list(), " ")<CR>
xnoremap * <esc>ms/\V<c-r>=<sid>get_visual_selection_searchpattern()<cr><cr> xnoremap * <esc>ms/\V<c-r>=<sid>get_visual_selection_searchpattern()<CR><CR>
nnoremap <silent> * ms:<c-u>let @/='\V\<'.escape(expand('<cword>'), '/\').'\>'<bar>call histadd('/',@/)<bar>set hlsearch<cr> nnoremap <silent> * ms:<c-u>let @/='\V\<'.escape(expand('<cword>'), '/\').'\>'<Bar>call histadd('/',@/)<CR>
nnoremap <silent> g* ms:<c-u>let @/='\V' . escape(expand('<cword>'), '/\') <bar>call histadd('/',@/)<bar>set hlsearch<cr> nnoremap <silent> g* ms:<c-u>let @/='\V' . escape(expand('<cword>'), '/\') <Bar>call histadd('/',@/)<CR>
" Use the setting of mark trick for backward search as well.
nnoremap <silent> # ms#<CR>
nnoremap <silent> g# msg#<CR>