Ack.tmbundle: a faster "Find in Project" for TextMate

Posted by trevor Tue, 03 Jun 2008 19:19:39 GMT

Recently one of my ENTP colleagues switched me on to ack as an excellent replacement for find+grep. Being a dyed in the wool TextMate user, the first thing that popped into my head was “I need an ‘Ack in Project’ TextMate plugin”.

Unfortunately the only advertised plugin I could find was 404’ing on me. Did I do the simple thing and notify the author about the dead link? Nope. I wrote my own plugin instead.

In hindsight I have to ask… what on earth was I thinking?

Whatever. I wrote the plugin and (if I do say so myself) it’s pretty damn good.

Here’s some installation instructions for getting it from my github repository:

cd ~/Library/Application\ Support/TextMate/Bundles
git clone git:// Ack.tmbundle

I’ve also thrown together a little (silent and slightly crappy) screencast showing it in action.



I’ve updated the wiki to include some information on getting ack to recognize new file types using Henrik’s haml comment as an example.


  1. Henrik Nyh said about 14 hours later:
    Looks nice! The UI is a big improvement over Grep in Project, for sure. You don't seem to be using the search clipboard (like Grep in Project does). Also, results returned between the two (Ack/Grep in Project) are different. E.g. when searching for "See all" from the root of a project (can't share the files; closed source), GiP finds 15 matching lines. AiP (set to literal match, case-insensitive) finds 4 matching lines. Possibly it ignores filenames like "_foo.html.haml". Could be the initial slash or the double extension? To try this hypothesis I created a new project, mkdir proj echo sesame > proj/_foo.txt echo sesame > proj/bar.txt mate proj but AiP doesn't find either file, searching for "sesame" (literal, case-insensitive). Am I missing something?
  2. Henrik Nyh said about 14 hours later:
    Ate my linebreaks :(
  3. jeff said about 17 hours later:
    awesome. only one annoyance I've found so far. If you search and find something, then return to your editor window, then use the shortcut to go back to the search: if you cancel out the search there, it clears out the previous search window. it would be nice if it left it there.
  4. jeff said about 17 hours later:
    to be clearer (hopefully). if i search for "pants" and click one of the results and go to the line containing "pants." then use the shortcut to get back to the ack search window with the intent of clicking another instance of "pants," I would like to be able to close the search prompt and just interact with the previous result window.
  5. Trevor Squires said about 21 hours later:
    @Henrik - I've edited the wiki on github with information on how to add file types to ack's list of interesting files (link is in an article edit above).
  6. Trevor Squires said about 21 hours later:
    @jeff - yeah it is annoying. I experimented with a number of strategies to overcome it but I've come to the conclusion that, as a .tmbundle, there's not much better I can hope for. As a result, I've been looking into creating a full-blown plugin version and that ought to eliminate this type of problem. For now I'd recommend using command-backquote to switch between the results window and the editor-proper.
  7. foz said 2 days later:
    Why not use rak? ( My current favorite code search tool, in ruby, easy to install (no CPAN) and has all the same features!
  8. Trevor Squires said 2 days later:
    @foz - thanks for the feedback. I'm not using rak because it doesn't have a few features that I want to take advantage of. Also, Ack.tmbundle includes the version of ack which requires no modules beyond what's in core Perl.

(leave url/email »)