[Update 2010-09-20: tweaked to run the grep on the git root instead of whatever directory the current file is in.]
After many months of screwing around with git.vim and fugitive.vim, I have
finally found the perfect vim + git grep combination.
This incantation allows you to press <ctrl-x> twice on a symbol and have a
minibuf pop up with all the occurrences of that symbol within the project. You
can then jump to any occurrence by pressing enter on the corresponding line.
Place this in e.g. ~/.vim/plugin/git-grep.vim:
let g:gitgrepprg="git\\ grep\\ -n"
let g:gitroot="`git rev-parse --show-cdup`"
function! GitGrep(args)
let grepprg_bak=&grepprg
exec "set grepprg=" . g:gitgrepprg
execute "silent! grep " . a:args . " " . g:gitroot
botright copen
let &grepprg=grepprg_bak
exec "redraw!"
endfunction
func GitGrepWord()
normal! "zyiw
call GitGrep(getreg('z'))
endf
nmap <C-x><C-x> :call GitGrepWord()<CR>