Chapter 5. emacs

Table of Contents
Basic editing
Emacs modes
Copy, paste, and cut
Learning more about emacs

It should be noted that emacs is a text editor and not a word processor. It is thus good at manipulating text rather than formatting text for viewing. Documents written with emacs are usually intended as input to programs, as e.g. compilers. To format text to be comfortably readable by humans one may either use openoffice (a wysiwyg, "what you see is what you get"-editor similar to Microsoft Word) or the TeX/LaTeX system that performs typesetting based on a file with ordinary text mixed with control commands.

To start emacs type emacs & to a shell:

$ emacs &

It is also possible to give emacs the name of a file to edit on the command line.


Basic editing

As a first exercise you should change your prompt to "Your.Name$ ". To start emacs for editing .tcshrc, write

$ emacs .tcshrc &

Now move the cursor after the last line, and enter a line like:

set prompt='Albert.Einstein:%~$ '
There are some good reasons to keep the prompt as a single word. Use the Save button on the toolbar to save the file. To check that the change is in effect write xterm & in your shell or click on the Terminal button to open a new xterm with a new tcsh process. This one should now have a different prompt.

Even though it is possible to control emacs with the menus, it is good to learn a few control sequences:


Emacs modes

emacs autmatically adjusts some of its behavior to the kind of document that is in the buffer. Each buffer is in one major mode at the time. The names of the chosen modes (both major and minor) are written within parenthesis at the line below the buffer itself.

C-mode is the mode that is automatically chosen when editing files ending with ".c". A pecularity in this mode is the automatic indentation.

Since the indentation mechanism knows C syntax rather well it is useful for spotting some editing errors as e.g. the omission of ";" at the end of a C statement.


Copy, paste, and cut

To copy or cut we first need to select a region. That is done by

The "marked region" is then colored differently from the other text.


Learning more about emacs

If you would like to learn more about emacs, there is built in help about a lot of things. By selecting TUTORIAL from the Help-menu or by typing C-h t a tutorial is started.

emacs is also fully documented within the info system.