(All feedback about this gratefully received, beginners or pros. Leave a comment.)

Emacs (and its cousin XEmacs) are enormously powerful text editors. Not so great for writing letters to your grandma, but fantastic for editing programming languages or LaTeX. Problem is, they’re so powerful that it’s easy to get lost when you’re starting. Someone shows you the key combo for that handy paragraph filling command… and a day later you’ve forgotten it again. These tips are for beginners, but they’re not about basic Emacs usage. Instead, I’ll try and describe where and how to look for information in Emacs itself about how to use it. As far as possible I’ll avoid arcane key combinations; the idea is to have a few words you can remember, and then use them to recover the magick combos when you forget them.

(Is this stuff useful? Well, there’s a lot of key combos. I use this lookup stuff at least once a week. You could keep a copy of the manual on your desk. It’s 600 pages or so, and I’ll bet I’m still quicker finding what I need.)

Basic basics

If you want a gentle tutorial introduction, or you want a reference manual, start with C-h (hold Control, press h). These tips are somewhere in between.

We’re going to be doing everything by the keyboard, not using the menus at all. You need to know your Meta key (Mac users, this is pretzel; on Windows it’s Alt). Emacs standard is to write “M-g” for “hold Meta, press g”, and “C-g” for the same with the Control key.

The single line at the bottom of your window is the Minibuffer. Keep an eye on it, that’s where messages about what Emacs is doing come out, and you’ll use it for Emacs-internal commands.

Tab completion is your best friend. For almost everything that goes on in the minibuffer you can hit Tab (sometimes twice) to get a list of possible commands. Type a little, hit tab again, and it will complete as far as possible; one more Tab and the list refreshes, filtered by what you’ve typed.

User functions

The M-x prefix drops you into the minibuffer to give the name of an Emacs user function: a lisp function intended for interactive use. Try it; give a couple of Tabs to see the list. (Scroll down with more Tabs.) Too many to make much sense of.

Getting information

Now try M-x describe and Tab through the list. These are the basic functions for getting information about Emacs builtins. If you know the name of the function you’re interested in, describe-function. With describe-bindings, you get a list of all the key combinations that are currently enabled, along with what they do. (Be careful: these depend on the current mode, so calling this function from a LaTeX buffer will give a very different result to calling it from the *Help* buffer itself.) Also useful are describe-mode and describe-key (the first for the current mode, the second also for longer key combinations).

Tab completion is great when you know some initial part of the function name (and the Emacs convention is that functions particular to some mode generally start with the mode name). If you’re less sure than that, try apropos. It asks for a regexp, but all you need is a word you’d expect in the function name. You’ll get a lot of dross, but the list of functions that apropos returns has a handy feature: click one (with the mouse or the Enter key) and you’ll get its description in a new buffer.

Bending Emacs to your will

As well as user functions, Emacs has a bunch of customisable variables. You’ll see them in the results from apropos, or you can use describe-variable if you know what you’re looking for. If they’re intended to be set by the user, they’ll have a line saying “You can customize this variable”, and “customize” is another hyperlink. You can also use M-x customize-option.

In the customisation buffer, there are lots of clickable buttons (depending on your version and Emacs family, they may look more or less like buttons). Take especial note of “State”: until you’ve clicked this nothing you change in the buffer actually makes a difference. It gives you a list of options; “Save for future sessions” will make the customisation more-or-less permanent. (You can find previously customised options in your .emacs file, usually in your home directory. Don’t edit this by hand unless you know what you are doing.)

Some handy customisations

Look these up using describe-variable and customize-option:

  • backup-directory-alist (put all your backups in one place, avoid all those messy ~ files)
  • global-font-lock-mode (syntax highlighting — if you don’t need it, why are you using Emacs?)
  • show-paren-mode (highlight matching or mismatched parentheses, good for LaTeX)
  • transient-mark-mode (show the current position of the mark — you might find this infuriating, you might find it useful)
  • tool-bar-mode (Emacs –non-X– only? This is good discipline: learn to use the keyboard!)
  • text-mode-hook and turn-on-auto-fill (break lines at natural points when typing)

Remembering it all

Use it. As simple as that. But you might also find the quick reference card handy. That covers all the stuff I deliberately avoided: basic text editing, movement, buffer control, &c. It’s also got the shortcut versions of lots of the information functions I described above.