diff options
author | Aaron LI <aly@aaronly.me> | 2023-06-13 09:25:20 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2023-06-13 10:02:50 +0800 |
commit | b2a692842652f27fa06f0d6fed7a5b491b6b46e8 (patch) | |
tree | 22ed2ec04d5d044e14ba6788a2cc842a51b02b41 /_vim | |
parent | fbb14398ea74ddf4f79d9a855536fa606a84087c (diff) | |
download | dotfiles-b2a692842652f27fa06f0d6fed7a5b491b6b46e8.tar.bz2 |
vim: Add config for instant grep + quickfix search
Diffstat (limited to '_vim')
-rw-r--r-- | _vim/vimrc | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -300,6 +300,24 @@ inoremap <F1> <Esc> vnoremap <leader>y "+y noremap <leader>p "+p +" Instant grep + quickfix +" https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3 +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 + " The Silver Searcher if executable('ag') set grepprg=ag\ --vimgrep |