aboutsummaryrefslogtreecommitdiffstats
path: root/vim/vimrc
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2023-05-13 14:49:09 +0100
committerMatthew Lemon <y@yulqen.org>2023-05-13 14:49:09 +0100
commit1a9cb0902dda5ba5c392519adfc62bab04cad205 (patch)
tree5c6b6c8d79e423daf826af08e4ddd1cdb7604a59 /vim/vimrc
parenta51b216d776a83b61c82cb169c906c4230539f5b (diff)
Adds a Grep function
This is from https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3
Diffstat (limited to '')
-rw-r--r--vim/vimrc12
1 files changed, 9 insertions, 3 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 347c264..7e2f804 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -539,10 +539,16 @@ set background=dark
" colorscheme gruber-darker
colorscheme blue
-
-function! Grep(args)
- return system('ag ' . a:args)
+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>)
+augroup quickfix
+ autocmd!
+ autocmd QuickFixCmdPost cgetexpr cwindow
+ autocmd QuickFixCmdPost lgetexpr lwindow
+augroup END
" manual highlights
" highlight Visual ctermfg=black ctermbg=LightMagenta