Wednesday, March 25, 2009 
« Refinancing | Main | Riding Home in Daylight »
Ack!

On a StackOverflow question about favorite Vim plugins, I learned about Ack, a replacement for grep that's smarter about searching source trees.

Ack is written in Perl. The built-in :vimgrep is rather slow. It seems to have some Vim-specific overhead, such as creating swap files and executing BufRead autocmds. Ack is noticeably faster, though somewhat slower than GNU grep.

Which would you rather type to search a tree, ignoring the .svn and .git subtrees?

$ ack -i -l foobar
$ grep --exclude='*.svn*' --exclude='*.git*' -i -l -r foobar .

The ack takes 6 seconds to search 4500 files, while the grep completes in 2. This does not count the time that I spent trying to figure out the correct syntax and argument quoting for --exclude. The help says both --regexp=PATTERN and --exclude=PATTERN, but the latter is a glob (file wildcard pattern).

On Windows, I wrapped ack with pl2bat.

posted on Wednesday, March 25, 2009 8:40:10 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Related posts:
When Video Cards Go Bad
Win64 Vim 7.2.182
Exuberant Ctags and JavaScript
reStructuredText syntax highlighting
PBwiki 2.0
Dramaturgy: Vim
Comments are closed.