Simple Features that Set Emacs Apart
Clinton R. Dreisbach, Former Viget
I started using Emacs as my primary text editor about three years ago. After two weeks, it quit being a difficult experience. When I joined Viget and started programming in Ruby again after a stint in PHP, I shifted to TextMate, but that didn't last long. There are features in Emacs that I wanted all the time. Those features were not only what I'd grown accustomed to, but also were major time- and effort-savers. Here are the three features I missed the most. Even if they don't convince you to try Emacs, they can be helpful in evaluating whatever text editor you do use.
If you have ever used tabs in a program interface, the basic idea of buffers will be familiar. Each buffer is a separate workspace that you can switch between quickly. Unlike the tabs in most text editors, though, Emacs' buffers are not limited to containing files. They can contain files, scratchpad areas, shells, output from a running process, and anything else Emacs can access. This allows me to have
autotest running in one buffer,
bash running in another,
script/console) in a third, and the files I'm editing in the rest.
Having all my development tools inside one program is nice, but what makes buffers a killer feature is the ability to switch between them quickly. You've probably heard of Emacs' storied multi-key commands: to switch buffers, you use a simple one,
C-x b. (
C-x just means "hold down Control and hit the
x key.) Using this command will give me a list of buffers I can drill down into by typing a few characters from the name of the buffer I want, much like Quicksilver works. This may not seem like an improvement over typing
Cmd-] (or whatever it is on your platform) to transverse tabs, but when you've got 30 buffers open, it's a godsend.
The Kill Ring
"The kill ring" is a terrifying name for a simple concept: whenever you cut or copy text in Emacs, it puts the text in a ring, or circular array. (We use different terms for cutting, copying, and pasting in Emacs, but I'm going to use the common terms.) When you paste text, the last item put on the ring is pasted, but you can then iterate through the ring until the item you want to paste comes up. This helps a lot when I'm refactoring code: I can grab the bits I want to move in separate chunks, move to another area of the file or another file, and paste each chunk where I want. Pasting doesn't remove the text from the ring, so I can also bring back something from ten minutes ago if I need it again.
Even if you don't use Emacs, you can get some of this functionality with a better clipboard manager for your platform. I use Jumpcut for OS X.
Emacs key commands
Much ballyhoo has been made over the years about Emacs' key commands, claiming you have to use all ten fingers at once to get something done. The exaggerations aren't completely off-base (I have it on good faith that "Emacs pinky" is a real ailment, and I type
C-c ; f t to jump to a test from a model or controller in Rails), but they hide the real power of this system.
Emacs' basic key commands are available in many other places on your computer system. If you're using a Unix of any sort, your shell probably supports them. If you're using OS X, any text field also supports these key commands. The basic commands that may work on your system are:
C-a: go to the beginning of the line
C-e: go to the end of the line
C-f: move forward a character
C-b: move backward a character
C-p: move to the previous line
C-n: move to the next line
M-b: move back a word
M-f: move forward a word
C-k: delete everything after this point
C-d: delete the next character
M-f means "Meta-B," which in Emacs moon-language, generally means "Alt-B." In your shell, Emacs' cut, copy, and paste commands work as well.
Once these key commands were hardwired into my brain -- which only took two weeks -- I would reflexively hit them no matter what application I was using. Having this work most places was nice; suddenly having better movement, deletion, cut, and copy powers in my shell was amazing.
There are many other features in Emacs that make my work easier every day, but these three alone are enough to elevate Emacs over any other text editor I've used. In my next post, I'll talk about Emacs features that make it not only a great text editor, but a good development environment.