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:
You can start Emacs by using a command at your shell prompt such as:
emacs
emacs filename
| 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- |
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.
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 1 | expand the current window to fill the current frame |
| C-x 2 | split the current window into two |
| C-x o | switch to next visible window |
| C-x k | kill the current buffer |
| C-x s | save the current buffer |
| M-x print-buffer | print the current buffer |
There are other cursor movement commands, but these are the most basic:
| C-f | move cursor one character forward |
| C-b | move cursor one character backward |
| C-n | move cursor down to the next line |
| C-p | move 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.
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-k | Kill 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-y | Yank an element of the kill ring.Hitting C-y repeatedly cycles through the kill ring. |
| C-w | Kill the text between the mark and point.The text is saved in the kill ring. |
| C-d | Kill the character under the cursor. |
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.