CSCI 235: Emacs tips

Dealing with headaches

The "get-me-out-of-this-action" key is ^G.

Sometimes, if you are mixing mouse navigation with typing, you might leave a command uncompleted, which makes some wierd things happen. If that's the case, you'll see the command named on the bottom line of the window, below the status bar. To deal with that situation, click your mouse in there (so that your typing will go to the command), then either finish the command or abort it with ^G.

Of mice and menus

If you use the buttons or menus for opening and writing files, you need to know that the dialogs that pop up are written for a three-button mouse. In particular, when you are opening a file, middle-clicking on a file name will select it. The scroll wheel doubles as the middle button: you can click it.

Some useful key sequences

Emacs uses a few keys (such as ^X or ESC) as prefixes to other keys, instead of like a shift key. So some of these are multiple-key sequences.

^X ^FOpen (find) a file. (You'll complete the filename on the bottom line of the screen.)
^X ^SSave the current file.
^X ^WWrite the current file under another name. (You'll complete the filename on the bottom line of the screen.)
^KKill from the cursor to the end of the line. If you hit this several times in a row, what you kill will all be collected together.
^YYank back whatever was last killed.
^WKill (wipe) the highlighted text.
^AMove to the beginning of the line.
^EMove to the end of the line.
ESC g gGo to a line by number.

Files, buffers, windows, and frames

It will help if you remember a bit of the terminology that Emacs uses to refer to these related concepts. Note that you can have multiple files open, multiple frames, and multiple windows into various buffers within those frames. Splitting a frame so that you have two windows into the same buffer can be useful if you need to look at two places in the same file. You can also have a file open in a buffer without it presently showing on the screen. You'll find various ways to move among buffers in the "Buffers" menu, and you can also find ways to show a different buffer in your window by pointing the mouse at the buffer's name (usually the same as the file name) in the status line at the bottom of the window. You'll also find out that Emacs may have some additional buffers that don't correspond to files (with names like "Messages").

Displaying line numbers

Emacs is already set to show you what line number the cursor is on, which can be helpful for finding and fixing mistakes. The line number shows up toward the right side of the status bar below the text you are editing, as something like L23 to indicate that you are on line 23.

That friendly ampersand

Because all of the interaction with Emacs happens in a frame (window) that it creates, it does not need to use your terminal window once it gets started. So if you stick an ampersand (&) on the end of the command when you start Emacs, you'll get your command prompt back for further use. Note also that once you have Emacs running, you can use its commands to visit additional files; so you can often manage by starting it up just once for all the editing that you do in a session.
Cary Gray

Last modified: Wed Sep 11 12:34:07 CDT 2013

Valid HTML 4.01!