These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Introduction To Emacs

Classnotes | UNIX01 | RecentChanges | Preferences

Emacs can best be described as a working environment featuring an editor, a mailer, a newsreader, and a Lisp interpretor. It has been joked that Emacs has everything, including the kitchen sink. Emacs is in stark contrast with the vi editor we just looked it: Whereas vi is intended to be small and lean with only the functions you need for editing, Emacs is large and featurefull (some would argue bloated) with whatever functions you might possibly need for day-to-day life. In this class, we will only examine the Emacs editor functionality, but it is useful to know that it is more than just an editor.

Emacs was really the first GNU program. It was created by Richard Stallman long before the Free-Software movement ever began. In addition to normal Emacs (which is console based) there is a GUI version called XEmacs.

Emacs derives much of its power and flexibility from its ability to manipulate buffers. Emacs could be described as a buffer-oriented editor. Whenever you edit a file in any editor, the file is copied into a work buffer, and editing operations are made on the word buffer. In many editors, there is only one work buffer, allowing you to open only one file. Emacs can manage many work buffers at once, allowing you to edit multiple files at once. Emacs extends to concepts of buffers to cover any task. When you compose mail, you open a new buffer. When you read news, the news is fed into a buffer. Switching from one task to another is simply a matter of switching buffers.

The Emacs editor operates very much like a standard word processor. The keys on your keyboard are input characters. Commands are implemented with special keys such as control (CTRL) and meta (ALT). There is no special input mode, as there was in Vi, instead you type your text and if you need to execute a command, you use the CTRL key. Such an organization often times makes Emacs easier to use for UNIX newbies, however Emacs itself is anything but simple.

Starting Emacs

To begin Emacs editting a file 'myfile', you could use
 $ emacs myfile

When Emacs is run underneath a GUI (such as a Window Manager under X) it will run with GUI support (meaning you can used mouse-based editing and menu selection). If run from a console lacking a GUI, it will function the same but without mouse support.

To enter text, you simply start typing as you are always in input mode. Editing commands are implimented with the CTRL key. For example, if you wanted to move the cursor right, you would use CTRL-F (for forward), and to move the cursor left you would use CTRL-B (for backward). You can save your text at any time using "CTRL-X, CTRL-S".

Emacs Online Help

Emacs offers online help in the form of Texinfo files (just like what we saw in the 'info' command). You can access these using CTRL-H. If you want a quick "cheat sheat" of options, then a "CTRL-H, CTRL-H" will provide it.

Exiting Emacs

To exit Emacs without saving, you can use "CTRL-X, CTRL-C".

Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited July 18, 2003 10:29 pm (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.