Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 4: Basic Editing |  | Previous HourNext Hour
Sections in this Hour: |  |  |  |

## Hour 4
Basic Editing

Now it's finally time to get started learning the basic editing skills of Emacs. When you finish this hour, you will have learned enough to use Emacs as effectively as you might use any simple editor.

In this hour, you'll learn how to insert and delete text, move around in Emacs, cut and paste, and load and save files. Although it is a bit beyond the scope of this book, this hour also tells you about several functions that are very useful when you need to read in a new file.

## Inserting and Deleting Text

Inserting and deleting text in Emacs is as simple as typing on a typewriter. You simply type the text. If you wonder why I'm telling you this, you're obviously not a vi user (vi is an alternative editor in UNIX). In vi you must be in a special insertion mode to insert text, which is not the case in Emacs.

Caution - If you see the text C-h (Type ? for further options)-- in the minibuffer when you press the backspace key, your backspace key is misconfigured. This is beyond the scope of this book, but consult section 7.0, "Emacs Backspace Binding Problem," at the following URL: ftp://cs.uta.fi/pub/ssjaaa/ema-keys.html or look at items 112 and 113 in the Emacs FAQ (available on this book's CD-ROM).

In Emacs there are several different ways to delete text. The simplest way is to press the Backspace or the Delete key. In most newer Emacs installations running on X or in Windows, Backspace deletes the previous character, whereas Delete erases the following character. If neither of them delete the following character, you can press C-d (delete-char) instead, which does it. In Figure 4.1 you can see which key deletes what.

Figure 4.1
The Delete and Backspace keys.

There are several other ways to delete text in the buffers. This will be described later in this hour.

### Automatic Line Breaking when Typing

When you reach the end of the line, Emacs does not break the line for you; instead it indicates that the line continues onto the next one and lets the text continue there. The indication is located in the last column of the text with a backslash in GNU Emacs and a newline arrow in XEmacs (see Figures 4.2 and 4.3).

Note - Although you might not see any difference to you between breaking the line and continuing on the next, there most certainly is. Try to break the line yourself (by pressing the return key) and then make the window wider. You should notice that the broken line does not combine with the one at the location where you broke it. This isn't, however, the case when newline arrows or backslashes appear. In that case, if you let Emacs break the line for you and then make the window wider, the line wrap indicator vanishes and the two lines combine together.

Figure 4.2
Indication of continued lines in GNU Emacs.

Figure 4.3
Indication of continued lines in XEmacs.

After all I've told you about Emacs so far, it shouldn't surprise you that you can configure Emacs to do automatic line breaking when you reach a given column. This is described in detail in Hour 12, "Using Visible Means," but until then, it might help you a lot to know that you enable this by pressing M-x and typing auto-fill-mode (this is a minor mode).

Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 4: Basic Editing |  | Previous HourNext Hour
Sections in this Hour: |  |  |  |

© Copyright Macmillan USA. All rights reserved.