From d4f81fe865f4205248914a581edcb386cf5a5f5e Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 16 May 2022 18:25:12 +0530 Subject: [PATCH] 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. --- nvim/.config/nvim/plugin/visual-star-search.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nvim/.config/nvim/plugin/visual-star-search.vim b/nvim/.config/nvim/plugin/visual-star-search.vim index 198fa55..48c926a 100644 --- a/nvim/.config/nvim/plugin/visual-star-search.vim +++ b/nvim/.config/nvim/plugin/visual-star-search.vim @@ -15,9 +15,13 @@ func! s:get_visual_selection_searchpattern() abort endf " Read last visual-selection into command line -cnoremap =join(get_visual_selection_list(), " ") -inoremap =join(get_visual_selection_list(), " ") +cnoremap =join(get_visual_selection_list(), " ") +inoremap =join(get_visual_selection_list(), " ") -xnoremap * ms/\V=get_visual_selection_searchpattern() -nnoremap * ms:let @/='\V\<'.escape(expand(''), '/\').'\>'call histadd('/',@/)set hlsearch -nnoremap g* ms:let @/='\V' . escape(expand(''), '/\') call histadd('/',@/)set hlsearch +xnoremap * ms/\V=get_visual_selection_searchpattern() +nnoremap * ms:let @/='\V\<'.escape(expand(''), '/\').'\>'call histadd('/',@/) +nnoremap g* ms:let @/='\V' . escape(expand(''), '/\') call histadd('/',@/) + +" Use the setting of mark trick for backward search as well. +nnoremap # ms# +nnoremap g# msg#