A TextMate tip for Emacs users 1

Posted by sjs
on Tuesday, July 03

Update: The only place I've seen this mentioned is in a comment on the MacroMates blog.

My Linux box is down due to a hardware failure; a cheap SATA controller to be specific. Perhaps that will be a story for another day. As a result I've been working on my MacBook and back in TextMate. Old habits. And I haven't gotten comfortable in any of the OS X Emacsen yet.

This gave me an opportunity to accidentally discover some shortcuts in TextMate. A result of the Emacs shortcuts that my fingers are already wired to, here are some TextMate keyboard shortcuts that may or may not be documented (I need to RTFM some day).

  • As in most Cocoa text areas, C-f, C-b, C-n, C-p, C-a, C-e, and C-t work as expected (and others I'm sure).
  • C-k: behaves as a vanilla Emacs, killing till a newline or killing a bare newline. I use the word killing specifically because you can yank it back with...
  • C-y: yanks back the last thing on the kill ring (paste history). You still have to use C-S-v to yank previous items.

I think TextMate may have helped ease me into Emacs without me even knowing. I had my suspicions that Allan was an Emacs fan and now I'm certain of it. I keep finding things in one that the other has, which makes switching between them easy. Well done Allan.

Comments

Leave a response

  1. Ches MartinSeptember 24, 2007 @ 11:39 PM

    While I concur that this is great stuff, and in saying "well done Allan" in general, he got this behavior for free in TextMate :-)

    Everything you mentioned (with the exception of C-S-v which *is* TextMate-specific) is standard behavior for NSTextArea, the de facto text area class in Cocoa. In other words, they'll work in most OS X-native applications! This rocks. I've used a few while typing this comment in Camino :-)

    A handy addition to your list is C-d, for forward-delete. You get even more Emacs-like goodness in Terminal.app when you enable the "Use option key as meta key" option in the 'Keyboard' section of Window Settings (be sure to make it default!), along with a few suggestions fromm the Macromates blog. That'll give you Opt-b and Opt-f for moving by word (just like Opt+arrows in NSTextArea, but no picking up your hands), Opt-backspace for delete word, Opt-d for forward delete word, and so forth. Sometimes I wish I could switch these on throughout OS X...

    Happy hacking.

Comment