Skip to content

Instantly share code, notes, and snippets.

@dsummersl
Created May 7, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsummersl/c37c8f35111f20aaa1d4 to your computer and use it in GitHub Desktop.
Save dsummersl/c37c8f35111f20aaa1d4 to your computer and use it in GitHub Desktop.
" Execute something on all files of the same kind:
"
" See GG and AA commands:
function! s:ExecFileType(cmd,search)
let extension = substitute(expand('%'),'\v^.*\.',"","")
exec printf("silent %s",printf(a:cmd,a:search,extension))
endfunction
command! -nargs=1 GG call s:ExecFileType("Ggrep %s -- '*.%s'",'<args>')
command! -nargs=1 AA call s:ExecFileType("Ag %s **/*.%s",'<args>')
command! -nargs=1 AA call s:ExecFileType("Ag %s **/*.%s",'<args>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment