I’ve been an avid Emacs user since college. I used it (along with LaTeX) to write, edit, and publish all my essays and theses. It was my FTP client, my mail reader, and, on occasion, my browser. I’ve used it to write web pages, screen plays, comic books, and every non-cocoa program I’ve ever compiled. Seeing Emacs on the command line was what convinced me OS X was a good idea. Finding a carbon port of it was a prerequisite of my moving to a Mac.
After all these years together, why am I now unceremoniously dumping Emacs without so much as a small redeeming twinge of guilt? It’s all because of this spunky little editor called TextMate. With all the love I have for Emacs, making the move to TextMate is still a no-brainer. Why? Two simple facts:
Down With C-x!
There are 101 keys on your average keyboard. The number of commands in Emacs is some value exponentially greater than this. So how does Emacs let you enter all those commands? Through prefix keys. Most of Emacs’s interesting commands take more than one set of keystrokes to access — first you type a prefix and then you type the actual command. For example, to open a file, you have to press
ctrl-x and then
ctrl-f. Even exiting Emacs takes multiple keys:
ctrl-x and then
ctrl-c. Remembering all these combinations of key presses is no easy feat. And actually typing them all leads to worn-out keyboards, RSI, and tears.
The best thing TextMate has going for it is its lack of this “feature”. No prefix keys! Every command in TextMate is accessible with a single key combination. Does that mean TextMate has fewer commands to offer than Emacs? Not at all! TextMate is just smarter about how it uses them.
The idea is so simple that it borders on genius. Every function in TextMate is bound not only to a key combination, but also to a context.
cmd-R may reload the current browser when editing an HTML document, but it compiles and runs your program when editing ObjC files. Depending on the context (which file is loaded), the same key combination (
cmd-R) performs different functions.
So far, this is not new — Emacs supports something akin to this using hooks to load minor modes for certain file extensions. But TextMate makes it revolutionary by increasing granularity. Not only are key combinations sensitive to what types of files are loaded, they are also aware of language grammar.
Imagine if, when writing code, your quote key inserts quotes normally within the source, but inserts escaped quotes when pressed inside a string? Or what if
Cmd-I inserts a
class template when in a java file, but then inserts a method template when pressed inside a
class? And what if this same command prints an
if() block when used inside a method! That’s the type of smarts TextMate has going on under the hood.
Don’t get me wrong, being fluent in a programing language from 1958 gets me plenty of trim at parties. But apart from its outdated syntax and the fact that Emacs is the only reason I ever have to dust off my lambda calculus hat anymore, Lisp is just not well-suited to the task of munging text. And what do you to all day in a text editor? Munge text! So why use Lisp as the backbone of your editor when a modern scripting language like, say, perl makes so much more sense?
But hey! Why limit yourself to perl? OS X ships with a plethora of scripting environments including bash, ruby, python, and others. Each has its own subtle strengths and weaknesses. TextMate lets you use all of these languages (and any other script interpreters or commands you can call from a shell) to build powerful text-manipulating macros. And it lets you do this all through its visual and highly-organized “Bundle Editor” so you don’t have to worry about messy include paths or dependencies.
Emacs, more often than not, struggles to be its own operating system oddly embedded inside of unix. TextMate, on the other hand, is a text editor that elegantly embeds unix functionality with as much HIG chrome as you please. The result is more focused and friendly than the Emacs/Lisp system, and yet sacrifices very little of the flexibility Emacs is known for (at least when it comes to editing text).
But don’t take my word for it. Check out some of the screencasts that show off what TextMate can do.