Emacs tutorial

Quickie Intro to Emacs


This document is a very brief intro to Emacs, one of the most popular editors among UNIX progammers. It is very powerful, chock full of features, fully customizable and extensible using Lisp, and very easy to use under X Windows. The other main alternative is vi. If you choose to use vi you're on your own, but then if you're sadistic enough to use vi then that probably suits you fine.

For more information on Emacs, click here for a handy Emacs reference card, Emacs FAQ, etc.

Starting Emacs

Emacs can be started in two modes: text terminal mode and X windows GUI mode. If you're using X windows, to start Emacs, type:
  emacs &
The ampersand character will place Emacs in the background so that you can continue to use the xterm window. Using Emacs under X is nice, since you can use the nice menu bar at the top of the screen to do most everything.

If you're dialing in over a modem and just have a text screen, type:

  emacs
From the fact that you have no DISPLAY environment variable, Emacs will deduce it is simply to use a text mode.

Opening a File

To open a file in Emacs, type ctrl-x ctrl-f and then type the name of the file followed by the ENTER key. This will create a new buffer for editing the file.

Editing a Buffer

Editing a buffer in Emacs is very like any word processor on Windows or the Mac.

Saving a Buffer

Type ctrl-x ctrl-s to save the current buffer. Type ctrl-x s to save any modified open buffers.

Closing a Buffer

Type ctrl-x k to kill an open buffer.

Getting Help

Type meta-x info to enter the "info" system, which is a hypertext help system within Emacs. It has help for many other GNU tools as well. The "meta" key is usually the Alt key if you're using X, or the escape key if you're using text mode.

Other Cool Stuff

Emacs allows tab-completion, like tcsh.

Since Emacs is largely written in Lisp, it is fully customizable by using Lisp commands entered while using Emacs or (more often) loaded automatically from your ~/.emacs file when Emacs is started up.

Since Emacs extensions can be written in Lisp, many people have added amazing capabilities to Emacs over the years, including syntax coloring (under X), RCS/SCCS/CVS source code version control commands, a compile mode, a mail mode, and much, much more. See the Emacs info page or your local Emacs guru for more information.


cse451-TA@cs.washington.edu