Skip to content

Instantly share code, notes, and snippets.

@habahut
Last active August 29, 2015 14:02
Show Gist options
  • Save habahut/bffde323e140fd6d5bdb to your computer and use it in GitHub Desktop.
Save habahut/bffde323e140fd6d5bdb to your computer and use it in GitHub Desktop.
Ack-grep tool for vim, put in .vimrc
:GrepTab <search term> <path> will open a new tab and show you all results from ack-grep of the search term on the path given. No path will default to current directory
(I recommend you ad `set autochdir` to your .vimrc as well, so that the "present working directory" is always at the file your editing. It makes searching for stuff easier)
nnoremap <leader>f :GrepTab "example binding
function! s:NewTabGrep(...)
let args=split(a:1)
if len(args) == 2
let dir=args[1]
else
let dir='.'
endif
echom args[0] . " " . shellescape(dir)
tabnew | execute "r ! ack-grep ". shellescape(args[0]) ." ". shellescape(dir)
endfunction
com! -nargs=? GrepTab call s:NewTabGrep('<args>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment