Brief Emacs Tutorial

In this short document we describe how to create and edit files using emacs. You should work out the examples as you go. Commands that you type are diplayed like this.

There are two important keys that you need to do emacs commands. These are the control and meta keys. Sadly, different manufacturers put these in different places and sometimes they even label them differently. The meta key is often labelled escape or ESC.

Examples of commands

From now on we will abbreviate commands as above. Remember that (a) for control commands you hold the key down while you type a letter, while (b) for meta commands you tap the meta key, then tap the letter.

Contents

  1. Your first file

Lesson 1. Your first file

The first thing to do is to learn how to start emacs, type something, save your work. Begin by typing the command emacs. Once you are in emacs, type sonething, e.g., a short note to a friend. Notice that you can back-space to correct errors. We will learn more about correcting errors and making changes later. If emacs is not set up to "wrap text", then you might see lines like this:

This is a test: one-two-three-four-five.  This is a test: one-two-three-four-fi\
ve.  This is a test: one-two-three-four-five.

The word "five" has been wrapped in an unpleasant way. To reformat it, type the command M-q.

If by any chance you type a "bad command" by mistake, you can try to restore emacs to a calm state of mind with the command C-g. If the screen becomes garbled, use C-l.

Once you have typed a paragraph or so and made it look right with M-q, you should save your work. You save it in something called a "file." To do this, use the command C-x C-s. You will see something like this at the bottom of your emacs screen:

  File to save in: ~/

Type "foo". This will be the name of your file. The line at the bottom of the screen will look like this:

  File to save in: ~/foo

Tap the return key to complete the command. You will then see something like:

  Wrote /u/ma/jeremy/foo

It is now time to wrap up this lesson. We do so by quitting emacs. For this use the command C-x C-c.

Summary of commands for lesson 1