TextMate Cheat Sheet for Rails Hackers

(Wed May 03, 2006) [/Rails#

Knowing your way around the editor you spend your Rails coding life in can do wonders for your productivity (and your typing fingers will thank you!). For me, that editor is TextMate on Mac OS X. TextMate has a dizzying array of magic keys and snippet activations that help you effortlessly slice through code. And if the built-in goodies aren't enough, you can easily create your own. But trying to fit all those keybindings into my brain in one go is a recipe for quickly forgetting them all. Rather, I like to start by learning the high-return tricks, use them enough so that they become a reflex, and then pick up bonus surprises as I go.

Ruby is an expressive language that wants programmers to type less, and yet I continue to be impressed by the folks who actually go to the trouble of typing in validates_presence_of. I for one have never managed to spell it correctly (this time included) and I feel exhausted even when I try. But I've come to the stark realization that the situation is actually much worse. (Yes, I'm exaggerating a wee bit here for dramatic effect.) When Dave and I live code during training, folks always want to know what keys we're hitting to make the magic happen. Nevermind the possibility that we may have just demonstrated how to map every legacy schema known to humankind and finally put a long-overdue end to the confusion that is symbols vs. strings (all in one line of code, mind you). It simply doesn't matter, because everyone became obsessed with finding out what hot key we used an hour ago and they haven't heard a word we've said since.

So with a genuine desire to help folks get a little more out of each programming minute, I decided to share the coffee-stained, threadbare cheat sheet that's been faithfully with me in one form or another since I started using TextMate.

The TextMate Cheat Sheet for Rails Hackers includes the trusty shortcuts I use on a daily basis. Many of these were graciously handed down to me from other Rails developers I respect who also reviewed the cheat sheet. (Hint: Every Rails hacker I polled uses Command-T to navigate files, rather than using the tabs or the mouse.) It intentionally doesn't include every possible shortcut. To help you discover more, I've added the key sequence for all the commands and snippets in the header of those sections. I tested it with a clean install of TextMate version 1.5.1 (build 985) installed from Preferences-Software Update-Check Now.

I hope this humble cheat sheet serves you well. After you've mastered these shortcuts, make it a point of pride to learn at least one new feature of TextMate each day. And most important, have fun!