diff options
Diffstat (limited to 'vim')
-rw-r--r-- | vim/grep.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vim/grep.vim b/vim/grep.vim new file mode 100644 index 0000000..93f52fb --- /dev/null +++ b/vim/grep.vim @@ -0,0 +1,17 @@ +set grepprg=ag\ --vimgrep + +function! Grep(...) + return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' ')) +endfunction + +command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>) +command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>) + +cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep' +cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep' + +augroup quickfix + autocmd! + autocmd QuickFixCmdPost cgetexpr cwindow + autocmd QuickFixCmdPost lgetexpr lwindow +augroup END |