PSU Mark
Eberly College of Science Math Dept
MD17 - Emacs

What is Emacs?

Emacs is a text editor. It is powerful and extensible because it is based on Emacs Lisp which allows the community of Emacs users to develop and share Emacs Lisp programs that expand the functionality of Emacs. For the history of emacs and a nice overview, see the wikipedia article on emacs.

The primary sources for information about Emacs are:

Quick Reference

Many people have written quick references for emacs, here are links to several:

Starting Emacs

You can start Emacs by using a command at your shell prompt such as:

     emacs
     emacs filename

Command Prefixes

M-The escape key. Many Emacs commands consist of the escape key followed by another key.
C-The ctrl key. Many Emacs commands consist of the ctrl key pressed at the same time as another key.
Ctrl-Sometimes people write Ctrl- instead of C-

Quitting Emacs

To quit Emacs, use the command: C-x C-c. That is, hold down the ctrl key and press x followed by c.

Edit a file

You can edit a file by giving the filename on the Emacs command line. You can also open a file using the command C-f. You will be prompted for the filename.

Buffers, Windows, and Frames

In Emacs, a buffer is a structure that contains, besides other data, the text that is currently being edited. Windows are sections of an Emacs frame. A window displays part of a buffer. Emacs was first written before windowing systems were common. A frame is what most GUI framewords call a window. Under a windowing system, you can have multiple Frames.

C-x 1expand the current window to fill the current frame
C-x 2split the current window into two
C-x oswitch to next visible window
C-x kkill the current buffer
C-x ssave the current buffer
M-x print-bufferprint the current buffer

Cursor Movement

There are other cursor movement commands, but these are the most basic:

C-fmove cursor one character forward
C-bmove cursor one character backward
C-nmove cursor down to the next line
C-pmove cursor up to the previous line
M-<move cursor to the beginning of the buffer
M->move cursor to the end of the buffer

In addition to the keystrokes above, the cursor can be controlled with the arrow keys on most keyboards.

Cutting and pasting

Many editing commands reference a points in a buffer called the mark and the point. The mark can be set with a command. The point is simply the current position of the character.

M-@Set the Mark.
C-kKill the text between the point and the end of the current line.
The text is stored in the kill ring. It can be yanked back.
Hitting C-k multiple times, kills multiple lines.
C-yYank an element of the kill ring.
Hitting C-y repeatedly cycles through the kill ring.
C-wKill the text between the mark and point.
The text is saved in the kill ring.
C-dKill the character under the cursor.

Configuration

On startup, emacs reads a file in the user's home directory named .emacs. It is a place to set variables that modify the behavior of emacs. For example, you can turn on/off syntax highlighting for a particular language, customize the colors that emacs uses for various types of syntax, or bind commands to keystrokes in general or per mode.

Mathnet Footer Map
Mathnet Sitemap Search
Privacy and Legal Statements Validate HTML Validate CSS