Atlas · Details
Effective Emacs
Author’s note
In 2006, all the best engineers used Emacs. Practically every respondent to the Stiff Asks interview used Emacs, except for James Gosling... who co-invented Emacs. It was the light saber of editors for those who took the time to delve into it.
Today, this post is essential reading if you have a time machine. Otherwise, it's not going to help you, because as of 2026, Emacs is no longer a real differentiator. Even I find myself using only a tiny fraction of its power anymore, like using a Lamborghini SUV for grocery shopping.
AI Notes
Ten-tip tutorial framing Emacs as a virtuoso's instrument: economy of motion, mastered the way a concert musician masters a phrase, with the mouse as the violation. Every tip flows from that frame. Swap Caps-Lock and Control so the pinkie never leaves home row. Rebind M-x to Ctrl-x Ctrl-m because Alt is awkward and unreliable over ssh. Prefer backward-kill-word to Backspace, because at 50 wpm killing the word and re-typing is faster than painstaking correction. The middle covers incremental search as the primary navigation tool, the buffer-window-frame distinction, and the case against menus and dialogs; the closing tips turn to regular expressions and the surgical text-manipulation commands — transpose-words, keyboard macros, kill-line semantics — that distinguish a power user from a wizard.
The practitioner's manual in a lineage that runs through My .emacs file, The Emacs Problem, and eventually Emergency Elisp, js2-mode, and Ejacs.
Related listings
-
2005
My .emacs file
Same year — the companion piece, showing Steve's actual config: a tiny .emacs file that loads a directory tree of ten thousand lines of personal Elisp and a quarter-million lines of community Lisp.
-
2005
The Emacs Problem
Same year — the philosophical counterweight. Effective Emacs is the practitioner's manual; The Emacs Problem is the architecture critique that explains why so much of Emacs still feels hand-cranked in 2005.
-
2008
Emergency Elisp
Three years later — once you have read Effective Emacs and started changing key bindings, this is the cookbook for writing the Elisp that backs them.
From the peanut gallery
Read the rest of the thread · 8 more
-
To yank at the i-search prompt, use
M-yinstead ofC-y. The emacs info node on Incremental Search talks about the rebinding ofC-y,C-w, etc at the i-search prompt.To repeat execution of the last kbd macro, after hitting
C-xeto run it once, keep hitting just theekey for repeated execution.Zap-to-char (
M-z) is incredibly useful if you need to changemyDatafileHandlertomyStreamHandlerand point is atD(the first char to change). SimpleM-z eto zap the "Datafile" part and type in the replacement. This is not orthogonal to thebackward-kill-word(bound toC-backspacefor me since that works in windows browser windows as well as everything else) so there's a feel needed for which is optimal when, which for me mostly depends on where point is already. -
Doing the swapping of control/cap-lock key can be done in \\HKEY_CURRENT_USER\Keyboard Layout instead of under \\HKEY_LOCAL_MACHINE.
-
To not pursue aggressive editor and keyboard customizations because other people stick to the standard is a bogus argument, in my opinion. Firstly, how often do you really use a terminal other than your own? And even then, how often do you write just scads of code there? When I do this, it's usually for just a couple of quick edits. So, why optimize for that 1% of time when you're not at your own setup? Secondly, if it does annoy me enough to care, I can always just load my rc file remotely. I use vim and have my .vimrc hardlinked into my /workplace directory so I can just say vim -u /net/ericw/workplace/.vimrc if I really need my magic. I'm certain the same can be done in emacs.
Customization is one of the main selling points of powerful editors, and our wrists are two of our most valuable assets as developers, so I don't understand why people eschew customization just because they fear that small percentage of the time when they won't have it.
-
Brian, I'm afraid I'm with Eric on this one.
I have friends who have nonstandard keyboards, in some cases to avoid repetitive-stress injury. I can't type at their workstations. I have this little secret, though, that works like a charm. I say: "uh, you type."
OK, not much of a secret, but it's gotten me by.
Everyone customizes their environment. Some SDEs use fonts so small I actually can't read them. Some use custom window managers with non-CUA hotkeys and behavior. People use Windows, Linux, MacOS. There are different Unix shells with different default keybindings and aliases. Should we tell everyone they have to use plain-vanilla Windows installations with no customizations?
You're effectively arguing that we should all reduce ourselves to the least common denominator of productivity. This argument has been debunked in other domains (e.g. should we make people with good vision wear blur-inducing glasses, so nobody feels like they're at a natural disadvantage?), and it doesn't hold water in ours either.
You're welcome to use the default bindings yourself, of course. But I wouldn't get on a bandwagon that tries to discourage people from getting better at their jobs. It's a slippery slope that I think you want to avoid.
Anyway, we now issue laptops with wireless iVPNs, so you can even bring your environment with you. It's just not an issue anymore.
-
I just want to know the tips you allude to in number (8) of your "Tune in next time..." section. How do you do the up/down/left/right browsing? I've been trying to train myself to use C-n, C-p, C-f, C-b and friends, but its awkward, and it isn't getting easier. Also, can I plllleeeeasssseee see your .emacs file :)
-
I know it's bad form to comment on a blog entry without having read it thoroughly but I will take a chance because your eternal salavation is at stake.
I use
C-hfor backspace in Emacs and movehelp-commandelsewhere:(global-set-key "\C-h" 'backward-delete-char-untabify) (define-key isearch-mode-map "\C-h" 'isearch-delete-char) (global-set-key [(hyper h)] 'help-command)and this also works in the shell along with
C-m,C-j,C-i, etc.Offered for your consideration. :-)
-
regarding tip #7, imho, its better to just disable it via Xresources, rather than loading it all up and making it invisible (as you have):
! better to turn this off here than in .emacs ! where it has already been loaded. emacs.verticalScrollBars: off -
Reading section 7, I became amused by the person who claimed that "countless studies" (or whatever) had proven that the mouse was faster. I'm guessing he never studied GOMS, which is a method of decomposing UIs into their basic operations and then performing objective complexity and time analysis.
A quick typist can hit about 10 keys per second, or .1s per key. To use a mouse there are four movements involved: move from the keyboard to the mouse, move the cursor to a location, perform some operation at the location, then move the hand back to the keyboard.
Moving the hand takes about .4s. Moving the mouse cursor on the screen takes .5s. So without even doing anything, you've used 1.3 seconds. A mouse click takes .1 seconds, and if you're dragging something, you measure the click down, the drag, and the release, adding up to .3s.
So let's say I want to highlight a line for copy:
.5 move cursor to first character .5 drag to highlight (and this is optimistic, depending on how good you are with finicky targets like highlighting) .2 copy (alt-w, ctrl-c, whatever. count control keys as a separate keypress)kb scenario 1: best case: already at beginning of line:
.6 seconds to perform, or nearly 4 times as fast.kb scenario 2: worst case: requires navigation: 30 lines down, line starts with "Reading":
.9s move to start of line (ctrl-r readi ctrl-r)As it turns out, the only thing a mouse is really good for is something involving a gross motor movement, like moving a window or the like. Unless you're a crappy typist.
Anyway, good article, and I'm looking forward to reading the rest of your blog rants.
I disagree with your agressive rebinding of keys. I used to rebind almost all my emacs keys so they would be more familiar to a windows user (Ctrl+C does copy, Ctrl+V is paste, etc). However, I found myself at a loss when I tried using my neighbor's computer with the default emacs installed.
Always learn default emacs keybindings first, then over-write them as you find appropriate. For example, I rebound Ctrl+J to be the goto-line macro. By default, Ctrl+J enters a newline. F7 is not bound to anything by default, so I made that bound to the compile macro (that keybinding actually comes from Visual Studio). That is about the extent of the keybindings I need/use. And, if I have to use a non-customized emacs, I can still get work done.
— Brian M · January 27, 2005 10:29 PM
"Swap Caps-Lock and Control": Or you could just get yourself a keyboard that's already swapped, or that lets you swap them in hardware. The Happy Hacking Keyboard is an example of the former. I like the Avant Stellar keyboard for the latter.
"Binding Alt-r and Alt-s": Try setting up a minor mode with the definitions you want. Then stick that keymap on the *front* of MINOR-MODE-MAP-ALIST.
Use `iswitchb' mode. It's faster for switching between buffers, and it provides more feedback.
Use P4 mode. But be sure to download a more recent version than what we have installed.
Emacs' integration with X11 selections is written to work well with xterm's sucky default policies. That means it works badly with modern apps and badly over slow network connections (say, a VPN from home). I have written a new set of commands to make Emacs talk to the clipboard, and they make life much easier.
— Derek U · January 24, 2005 07:37 PM