arrow_backward Back to blog

Vim Tip: Fast (and Easy) Project Searching

Our developers tend to have interesting conversations throughout the day in Socialspring Stream, our communication and collaboration application. It occurred to me today that it would make sense to take some of the useful tidbits of information that surface there and share them with the rest of the development community! After all, the conversations are captured already – all I need to do is bundle up the relevant bits of information and serve them to you via our blog; in other words, expect more quick posts of tips and tricks here!

Fast Project Searching With Ack

You can set ack to be grep within vim, in order to make searching within your project faster and more effective. It’s a great programmer search tool. Here’s how:

  • Install ack (instructions found here)
  • Then in your .vimrc file “set grepprg=ack”.
  • Then whenever you “:grep ” vim will use ack instead of grep!

Why would you do this? Because its so much faster! BetterThanGrep cites these reasons (among others) in this list on their site (full list here):

Top 10 reasons to use ack instead of grep

  • It’s blazingly fast because it only searches the stuff you want searched
  • ack is pure Perl, so it runs on Windows just fine. It has no dependencies other than Perl 5.
  • Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories.
  • Ignoring .svn directories means that ack is faster than grep for searching through trees.
  • Which would you rather type?
    • $ grep pattern $(find . -type f | grep -v ‘.svn’)
    • $ ack pattern
  • ack ignores most of the crap you don’t want to search
    • VCS directories
    • blib, the Perl build directory
    • backup files like foo~ and #foo#
    • binary files, core dumps, etc

Today’s Vim tip was brought to you by Adam Bair, who was giving another developer advice on grepping over a project directory. Check back often for more tips, or follow us on Twitter for timely notifications about similar tips and tricks!

arrow_backBack

New Project Request













Top