enable search with visual selection with highlight
fix issue @178
This commit is contained in:
parent
15bc8c1385
commit
4dc4017f69
1 changed files with 3 additions and 7 deletions
|
@ -199,8 +199,8 @@ set wrap "Wrap lines
|
||||||
""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""
|
||||||
" Visual mode pressing * or # searches for the current selection
|
" Visual mode pressing * or # searches for the current selection
|
||||||
" Super useful! From an idea by Michael Naumann
|
" Super useful! From an idea by Michael Naumann
|
||||||
vnoremap <silent> * :call VisualSelection('f', '')<CR>
|
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
|
||||||
vnoremap <silent> # :call VisualSelection('b', '')<CR>
|
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
||||||
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
@ -384,14 +384,10 @@ function! VisualSelection(direction, extra_filter) range
|
||||||
let l:pattern = escape(@", '\\/.*$^~[]')
|
let l:pattern = escape(@", '\\/.*$^~[]')
|
||||||
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
||||||
|
|
||||||
if a:direction == 'b'
|
if a:direction == 'gv'
|
||||||
execute "normal ?" . l:pattern . "^M"
|
|
||||||
elseif a:direction == 'gv'
|
|
||||||
call CmdLine("Ag \"" . l:pattern . "\" " )
|
call CmdLine("Ag \"" . l:pattern . "\" " )
|
||||||
elseif a:direction == 'replace'
|
elseif a:direction == 'replace'
|
||||||
call CmdLine("%s" . '/'. l:pattern . '/')
|
call CmdLine("%s" . '/'. l:pattern . '/')
|
||||||
elseif a:direction == 'f'
|
|
||||||
execute "normal /" . l:pattern . "^M"
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let @/ = l:pattern
|
let @/ = l:pattern
|
||||||
|
|
Loading…
Reference in a new issue