blog: Using ack (better than grep!) with Vim

Posted on 23 Jul 2010 under vim

If you’ve had to use grep enough times, you’ve probably heard of ack, which just like the domain name it’s housed on describes, is better than grep. If you haven’t been introduced to ack before, it’s basically every programmers dream come true when it comes to searching through code.

It’s quick, has a variety of great options, and takes about 1 minute to install. After seeing an article about AckMate I was inspired to find something similar for Vim, and of course — it exists!

First, install ack

You can install ack in a variety of ways but the one liner on the site provided does the trick, especially if you use ~/bin on your PATH for simple scripts like this

curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3

Once ack is installed, grab the awesome ack.vim plugin. You can also follow active development of this plugin (and read additional docs) at its Github Page

Installing the plugin is simple, just unpack the gzipped archive into your ~/.vim directory and you should be good to go.

mv ack.tar.gz ~/.vim
cd ~/.vim
tar zxvf ack.tar.gz

The archive will unzip ack.vim into ~/.vim/plugin and ack.txt into ~/.vim/doc. You now have it installed and can do awesome ack searching from within vim. Here’s an example result:

:Ack —python setup

The format to search is just like ack, so there’s no awkward adjustments. And that’s all there is to it, but now you don’t have to leave vim to use ack :)

References:

  • Others Posts You May Enjoy

    Thanks for reading. How about leaving a comment?

    blog comments powered by Disqus
  • Fork me on GitHub