Fixing a major TextMate annoyance

The Reevoo office is all-Mac, with the exception of one bargain-basement Windows XP box used for billing and debugging our website in Internet Explorer (to which, as regular readers will know, I bear an intense and righteous anger, but that’s not what I want to talk about today). We developers use TextMate as an editor. It’s a decent product with some well-thought-out features that really increase productivity, but it’s also hopelessly immature in many ways. In general, although I miss vim key mappings, I’m happy using TextMate for daily work.

Until recently, TextMate’s ‘Find in Project’ feature was really broken: its memory requirements when searching a large directory were so unreasonably huge that it would paralyse the operating system in half an hour of memory swapping ended only by the eventual death of the TextMate process. (In my estimation, Mac OS X’s memory management is also more than a little suspect.)

This sorry state of affairs would most frequently be triggered by attempting to search a large log directory in a Rails project. Given that running tests writes a lot to the logs, and we do a lot of testing, this was the rule rather than the exception. I had to learn not to use ‘Find in Project’ without first deleting everything in the log directory first. Sometimes I’d forget and get a very long enforced tea break. Whilst I enjoy breaks and recognise their health benefits, I prefer to take them on my own schedule—waiting for an unresponsive computer is anything but restful.

I’m happy to say that the rampant memory use has been fixed by a recent update to TextMate. Nonetheless, having to search the log directories makes searches much slower than they need be and tends to clutter the results. Ideally, I’d just like it to skip them entirely. Today, after five months of daily use, I finally worked out how.

Surely I can’t be the only one to have suffered this problem! I don’t think it’s just me being entirely daft: it’s genuinely difficult to find. Hidden in the Preferences dialog, behind the ‘Advanced’ section and in a tab named ‘Folder References, there is an input box labelled ‘Folder Pattern’. The name doesn’t really explain its function, but closer inspection reveals that it contains a regular expression telling TextMate which directories (or ‘Folders’ in Mac OS X parlance) it should ignore when loading a project.

TextMate Preferences screenshot

By default, it contains patterns for the data directories of a variety of version control systems. If we add log to these, it’ll ignore log directories too:

!.*/(.[^/]*|log|CVS|_darcs|{arch}|blib …

Next time we load a Rails project into TextMate the log directory simply won’t appear, and won’t be included in searches. Of course, if you actually wanted to look at the logs in TextMate, you’re out of luck—but then again, it can’t handle large text files anyway. Like I said earlier, it’s still an immature application.


  1. Jeremiah

    Wrote at 2006-07-29 20:56 UTC using Firefox on Mac OS X:

    Thanks for a good tip!
  2. Aaron Quint

    Wrote at 2006-10-05 16:13 UTC using Mozilla on Mac OS X:

    Ahah! I’ve been struggling wondering if there was away to do this. It was getting really painful, and not only do I have log directories in my project, but binary audio files as well.

    Thanks so much for this little nugget.
  3. Gabe da Silveira

    Wrote at 2007-05-18 19:15 UTC using Safari 419.3 on Mac OS X:

    The other trick is to right click on files and select “Treat File as Binary” in which case it won’t be searched. It goes by extension, so it’s not as fine-grained as the file and folder patterns, but it’s a good fix if you don’t want the files to disappear from the list.

    However there is another great use for the patterns, which is for large numbers of files. Every time you click in and out of TextMate it reconciles the file list, and if you have directories with large numbers of files this can result in a noticeable delay. Before reading this post I had resorted to ridiculous work arounds to keep my generated files (50,000 of them) out of the main project directory.

    Incidentally this was also my introduction to formal projects (up til now I had just opened directories). Great tip.
  4. Micah Winkelspecht

    Wrote at 2010-07-19 07:38 UTC using Firefox 3.6.6 on Mac OS X:

    You, sir, deserve a beer.
  5. Paul Russell

    Wrote at 2011-05-16 20:24 UTC using Safari 533.21.1 on Mac OS X:

    Amen. This was really getting on my nerves – thanks!