Smart Home in TextMate

I really like “smart home” behavior in text editors. That is, I like it when pressing the “home” key first moves the cursor to the start of the indented text on that line, and then to the very beginning of the line on a second press.

I go out of my way to enable this behavior, where possible. For instance, I wrote a gedit plugin to get it working properly in gedit, the Gnome text editor.

Unfortunately, TextMate is a harder nut to crack. I worked out the following as a TextMate command, and bound it to command-left:

It works, but is far too slow to be usable for me. There’s a perceptible lag of probably around 100-200ms between hitting the shortcut and the cursor moving.

I think this is an unavoidable limitation of TextMate’s approach to letting commands navigate within the file. It has to spawn a process to run the command, and the command then spawns a process to run the OSX command open which handles a txmt:// protocol that TextMate has registered with the OS. There’s some inherent inefficiency there.

(Writing a command with pure shell scripting doesn’t help, incidentally. It’s slightly faster, but still not enough to be worth it.)

TextMate bundle: Ack in Project (improved)

I use TextMate for work. It’s a good editor, doesn’t get in my way, and I take advantage of relatively few of its nifty features.

One problem with TextMate is that its built-in search is very slow, especially across a large project. Since I work with a full checkout of the deviantART source code, searches can take a while.

So I started using Ack in Project, a TextMate bundle that uses ack to search your project. (Ack is a nifty little tool that combines grep and find, along with a number of useful optimizations for searching checked-out source code.)

However, Ack in Project doesn’t expose a very useful part of ack’s functionality, which is the ability to search just particular filetypes. This has occasionally been a pain – some words appear commonly in PHP and JS files, but I only care about them in the PHP.

So I spent a little while this evening adjusting Ack in Project to let you choose a file type to search.

My Ack in Project tweak

My version is up on github.

If you’d like to use it, do this:

(It was my first time messing with tm_dialog, so I’m not necessarily confident about how I did it. But it works!)