From 4dc4017f69baf4229f6a7ab7ba7d1c289bfa805f Mon Sep 17 00:00:00 2001 From: dragonxlwang Date: Mon, 28 Mar 2016 15:26:02 -0500 Subject: [PATCH] enable search with visual selection with highlight fix issue @178 --- vimrcs/basic.vim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index 8bdc61c4..70439321 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -199,8 +199,8 @@ set wrap "Wrap lines """""""""""""""""""""""""""""" " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('f', '') -vnoremap # :call VisualSelection('b', '') +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -384,14 +384,10 @@ function! VisualSelection(direction, extra_filter) range let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") - if a:direction == 'b' - execute "normal ?" . l:pattern . "^M" - elseif a:direction == 'gv' + if a:direction == 'gv' call CmdLine("Ag \"" . l:pattern . "\" " ) elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') - elseif a:direction == 'f' - execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern