Emacs to TextMate, Part 1
Posted by Nick Sieger Fri, 13 Oct 2006 03:20:00 GMT
My name is Nick Sieger, and I’m an Emacs-o-holic. I’ve been using Emacs for over a decade, and my
.emacs file alone (excluding
custom elisp packages) has accumulated 125KB of cruft. Basic navigation keystrokes are beyond ingrained into my fingers, they’re
automatic. I was pleased when I found Jacob Rus’ explanation of the Cocoa text system and accompanying instructions for baking
these commands into the basic OS X text widget; now getting around Cocoa text widgets is a breeze.
Emacs, in a way, has a reputation for being something like the Spruce Goose of computer programming tools. Some view it as the pinnacle of achievement in text editing tools; a piece of art; the most extensible piece of software ever written. On the other hand, the learning curve is considered to be much steeper, and Emacs hasn’t changed visually very much over the years, sticking to a minimalist interface that doesn’t dazzle like tabby, tree-widgety, multi-paneled IDEs.
So it seems that I’m going to be continually comparing TextMate to Emacs; perhaps a subject worth expounding upon. As I ramp up on TextMate, maybe these findings and tips will become useful for anyone, Emacs user or not.
Things to like about TextMate
The “project” system is simple but elegant in its conception. Open a directory, and it becomes your workspace. Navigate to any file quickly with ⌘-T. I always wanted something like this in Emacs and considered writing one at one point.
Visually appealing. Renders fonts well, beautiful built-in color schemes, strong syntax-highlighting. The multiple, nested context highlighting is well done. At the same time, the UI is minimalist enough that you’re not distracted by gratuitous toolbars full of icons that you constantly have to hover for the tooltip to remember what they do.
Feels right. The app blends in well with the OS X user interface, and shares its philosophical underpinnings of simplicity and least surprise.
Broad language support. Many popular languages supported out of the box (notable exception: C# -- I wonder why), and if you get subversion bundles, many less common ones, e.g., Io, Lua, or OCaml (note to self: none of which I have had the chance to explore yet).
Community support and innovation. Seeing the buzz in the community around TextMate is strong evidence that it’s spurring some innovation, a fresh approach, in a category of software that hasn’t seen much for quite some time.
Emacs-isms I miss (or haven’t found yet) in TextMate
Text selection while staying on the home row. Setting the mark (C-SPC) and moving the cursor to select a region of text. I don’t like moving my right hand over to the arrow keys to make a selection! This is my number one new feature wish for TextMate.
Buffer selection with C-x b or C-x C-b to quickly jump to an already-open file. ⌘-T replaces this to some extent, but it’s not the same and requires some retraining. Update: ⌘-T RET is equivalent to C-x b. Good enough. One thing I have discovered that I like quite a bit is the ability to scroll through the buffer/file-selection box with C-n and C-p.
back-to-indentation. This is an emacs command that moves the cursor in front of the first non-whitespace character on the line and is bound to
M-mby default. This keystroke is apparently one that I use frequently, because my fingers keep typing ⌘-M which has the effect of minimizing the current window in TextMate. Ack.
open-linein Emacs is bound to C-o, which inserts a new line where the cursor is but leaves the cursor before it. The exact same command is in TextMate, and is bound to the same key. Sweet! But apparently my fingers are trained on a variation:
split-line, bound to C-M-o. This is similar to
open-lineexcept that it moves any text to the right of the cursor vertically down. When you’re sitting at the first non-whitespace character on a line and you split it, it has the effect of creating a new line directly above the current one, leaving you at the same indentation level. Yes, C-a C-o TAB pretty much does the same thing, but it’s three keystrokes instead of one.
hippie-expandis a powerful, extensible multi-completion mechanism that is hard to live without. TextMate’s ⎋ completion seems roughly equivalent to Emacs’
dabbrev-expand, but hippie can expand similar words and lines from all open buffers, making the completion that much more powerful and context-aware.
recenter(C-l). Puts the current line in the middle of the window, unconditionally. TextMate doesn’t appear to let you scroll the contents of the window such that the last line in the buffer is any higher than the bottom of the window. I prefer to have the line of code I’m editing closer to the center of the window.
string-rectangle. This versatile command allows you to replace each line in a rectangular selection with a prompted string value. Great for adding a column of tab characters, commas or other formatting to a group of similar lines. Update: I found the TextMate equivalent for this one. It turns out TextMate has a great rectangular editing facility, simply by starting a selection, tapping ⌥, and continuing. Typing while the rectangle is active inserts new text in the same manner as
What else have you found about TextMate that reminds you of Emacs or helps you get over it?
To be continued!