Created
September 1, 2016 13:57
-
-
Save sasq64/bb4e3c895c21859db533e628750e0291 to your computer and use it in GitHub Desktop.
Find functions and classes using silver searcher from vim
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! FindFunction(name) | |
cexpr! system('ag --vimgrep -G ".(cs\|c\|cpp\|h\|java)$" "[A-Za-z\*]+\s+([A-Za-z_]+::)?' . a:name . '\s*\([^\)]*\)\s*(?=\{)"') | |
endfunction | |
function! FindClass(name) | |
cexpr! system('ag --vimgrep -G ".(cs\|c\|cpp\|h\|java)$" "(class\|struct\|interface)\s+([A-Za-z_]+\s+)*' . a:name . '\s+(?!;)"') | |
endfunction | |
nmap <leader>af "zyiw:call FindFunction(@z)<cr> | |
nmap <leader>ac "zyiw:call FindClass(@z)<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment