Vim-grep

** use grep command to find selected words **

vim-grep/

  • plugin/
    grep.vim

function! s:GrepOperator(type)
  let l:saved_unnamed_register = @@
  if a:type ==# 'v'
    normal! `<v`>y
  elseif a:type ==# 'char'
    normal! `[v`]y
  else
    return
  endif

  silent execute "grep! -R " . shellescape(@@) . " ."
  copen

  let @@ = l:saved_unnamed_register
endfunction

nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<cr>g@
vnoremap <leader>g :<c-u>call <SID>GrepOperator(visualmode())<cr>

  • doc/
    grep.txt
posted @ 2023-02-08 20:15  箫笛  阅读(28)  评论(0)    收藏  举报