vim ♥ ack
viack opens the results of your ack search in vim.
For maximum Getting Out Of The Way, it invokes vim with a variety of options for stepping through results.
All matching files are loaded in the file list. You can use
:nto go the next file.
The search pattern is preloaded into the current search as a vim-compatibile regular expression (translated from ack/ag's PCRE). You can use
nto skip around in a file between matches. If you enable persistent search highlighting in vim, you'll see matches highlighted.
The quickfix list is populated with the hits so that
:cnwill jump to the line of the next result, moving to the next file as necessary.
viack is aliased as viag in case you want to search using ag instead of ack. It also integrates with git as:
- git viack
- git viag
- git vigrep
all of which use
git grep to do the searching (tuned to accept PCRE and
otherwise act compatible to ack/ag).
git ack/ag support via git-grep-with-smartcase
Adding two git aliases
ag to complement
suggested for maximal convenience and the least amount of finger retraining.
You can do so by running:
git config --global alias.ack "grep-with-smartcase -I --perl-regexp --break --heading --line-number" git config --global alias.ag "grep-with-smartcase -I --perl-regexp --break --heading --line-number"
I also like to make the default filename and line number colors match ack's:
git config --global color.grep.filename "green bold" git config --global color.grep.linenumber blue
:grep support with git-grep-or-ag
If you find yourself using the
:grep command to search files and load up the
quickfix list from within vim, you can opportunistically use
git grep and
ag if not in a git repo. In your
viack requires only Perl and the modules that ship with core Perl. Of course, you have to have ack/ag installed too. Installation is as simple as:
make install prefix=/usr/local
You can uninstall just as easily with:
make uninstall prefix=/usr/local
Just adjust prefix if you need a different path.