Commit 7bf8d37
Changed files (2)
plugin
plugin/grep-operator.vim
@@ -0,0 +1,29 @@
+nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<cr>g@
+vnoremap <leader>g :<c-u>call <SID>GrepOperator(visualmode())<cr>
+nnoremap <leader>f :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
+command! -nargs=+ -complete=file -bar FindInFiles silent! grep! <args>|cwindow|redraw!
+
+if executable('ag')
+ let g:ackprg = 'ag --nogroup --nocolor --column'
+ set grepprg=ag\ --nogroup\ --nocolor\ --column " the silver searcher
+ "set grepprg=ag\ --silent\ --vimgrep\ $*
+ "set grepformat=%f:%l:%c:%m
+endif
+
+function! s:GrepOperator(type)
+ let 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
+ redraw!
+
+ let @@ = saved_unnamed_register
+endfunction
vimrc
@@ -218,8 +218,6 @@ nnoremap <localleader>f :Ack<space>
nnoremap <C-n> :GFiles<cr>
nnoremap <C-p> :Files<cr>
nnoremap <C-e> :Buffers<cr>
-nnoremap <leader>f :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
-command! -nargs=+ -complete=file -bar FindInFiles silent! grep! <args>|cwindow|redraw!
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
@@ -227,11 +225,6 @@ omap <leader><tab> <plug>(fzf-maps-o)
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-l> <plug>(fzf-complete-line)
-
-if executable('ag')
- let g:ackprg = 'ag --nogroup --nocolor --column'
- set grepprg=ag\ --nogroup\ --nocolor " the silver searcher
-endif
" }}}}
"" Status Line {{{{