Created
June 6, 2014 15:06
-
-
Save egwynn/08dbb8b870b85cfe342a to your computer and use it in GitHub Desktop.
Ggrep for <cword> (in current dir or in 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
function! GitRoot() | |
let cmd="git rev-parse --show-toplevel" | |
let result=system(cmd) | |
if v:shell_error | |
echom "Error: [".result."] (\"".result."\")" | |
echom "Command: [".cmd."]" | |
return expand("%:p:h/") | |
endif | |
return result | |
endfunction | |
function! QFGGrep(path) | |
" let needle = s:get_visual_selection() | |
let needle = expand("<cword>") | |
execute "silent botright Ggrep -i ".needle." ".a:path | |
cwindow | |
endfunction | |
nnoremap <Leader>gg :call QFGGrep(expand("%:p:h/"))<CR> | |
nnoremap <Leader>ga :call QFGGrep(GitRoot())<CR> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment