Created
April 13, 2011 05:33
-
-
Save tcha-tcho/917013 to your computer and use it in GitHub Desktop.
A vim help to grep using the git root
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! -i -I -n " . 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> | |
command -nargs=? G call GitGrep(<f-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment