Fugitive.vim allows me to run git grep
commands; unfortunately, the results are not stored in a quickfix-list, so I need to run :cw
after a :Ggrep
in order to have an easily parseable result list.
I would like to type :Ggr "def my_function"
instead of:
:Ggrep "def my_function"
:cw
How can I define this :Ggr
command in my .vimrc file?
EDIT
Once the :Ggr
command is defined, I can map to git grep
on the word under the cursor, which is really awesome:
nnoremap <C-F> :Ggr <cword><CR>
:Ggrep
does fill thequickfix
list however the window does not automatically open. Maybe you want thequickfix
window to open after any grep invocation,autocmd QuickFixCmdPost *grep* cwindow
, as suggested on the vim-fugitive FAQ section. – Hyacinthus