VIM: ack instead of grep
I much prefer ack to the standard grep – it’s way better. If you are curious why – just open the ack page.
Replacing grep with ack in VIM is pretty easy: set grepprg=ack. But there’s a catch – ack does not output columns for search results, making search result navigation a nightmare – on each “:cn” VIM puts cursor at the beginning of the line and I have to do an additional search for the word. Definitely no fun!
Adding columns to ack turned out no big deal. Here’s how to do this (works for ack 1.86, so just get this version or tweak the patch file):
- Download Ack.pm.diff (taken from this thread: here, Eric Van Dewoestine, thanks a lot!).
- Find the location of Ack.pm in your system (may be multiple files), typically
locate Ack.pm. - Patch each
Ack.pm:sudo patch -p0 -b < /path/to/Ack.pm.diff /path/to/Ack.pm(if you have Ack.pm installed per user, please removesudo). - In your vimrc add the following:
set grepprg=ack --column
set grepformat=%f:%l:%c:%m
Enjoy!
April 23, 2009 at 17:39
I’m making an ack release today that will include a –with-column switch. Thanks for bringing it up again.
April 24, 2009 at 10:52
Andy,
That’s great news! Thanks for the very useful piece of software
.
April 24, 2009 at 08:52
[...] Настройка ack вместо grep для vim’a, VIM: ack instead of grep [...]