TextMate – My New IDE of Choice

A little less than a year ago I made the switch to OS X and treated myself to a Macbook Pro. Just recently, I started working with the TextMate IDE on a current contract.

My first impression was less than stellar. Visually, TextMate is pretty spartan. Applications on OS X are supposed to be pretty (see Coda). TextMate is most decidedly not pretty. But as I’m starting to learn, she’s got an amazing personality.

Sometimes it’s the little things that hook you in. For the longest time, I put off learning jQuery. Didn’t see the need. I’m pretty comfortable with JavaScript, and couldn’t justify investing the time to learn a new way to write what I already knew how to write. Then I learned about .toggle(). I was sold. I hopped into bed with jQuery and I’ve not looked back.

Today, I was introduced to TextMate’s equivalent of .toggle(). It may seem trivial, but it got me hooked, and hungry to learn more.

The hook, in this case, was code commenting. I am used to ⌘+SHIFT+M in CFEclipse, which adds a CFML comment around the currently highlighted code. With TextMate, I hadn’t bothered to RTFM. I was using it more as a version of TextEdit/Notepad on steroids than a true IDE, just typing without utilizing any of the shortcuts it provides. But today I asked a co-worker if he knew offhand how to add a comment in TextMate, and he showed me the keystroke ⌘ + / (command slash).

I’ll admit that doesn’t sound like enough to hook anybody… but what I noticed was that he demonstrated the keystroke on a cfscript block, and I was trying it on a CFML block. And in both cases, the same keystroke inserted the proper comment syntax. On the CFML block, I got <!— —>. On the cfscript block, he got //. Based on the context of the line of code, the IDE knew which type of comment to insert.

OK. Now I was paying attention.

I opened up an .XML document, hit the same keystroke, and got a proper XML style comment (<!– –>). Again, the IDE was intelligent enough to know based on the file type, which type of comment to insert. That’s the point at which I was hooked. If you’re like me (and you wouldn’t admit it if you are), you’ve made the mistake more than once of using a CFML type comment in an .XML file, only to have your application blow up at runtime. With TextMate… no more. Remember the single keystroke, and know that regardless of the file type, or whether or not you’re commenting CFML or cfscript, you’re going to get the proper comment inserted.

A picture’s worth a thousand words. Because you’re all very special to me, I’ve done you one better. Have a look at the video below:

EDIT: Unless you’ve got -really- good eyes, you probably don’t want to watch the embedded version