Go to the previous, next section.

Getting Started

Welcome to Emacs. Learning Emacs may seem a daunting task, but spending a few minutes learning Emacs, can save you many more in the future. Emacs is an extremely powerful editor and many of tasks you now do from the command line and using different applications can be done from inside of Emacs.

The section contains a brief tutorial on some of the basic operations of Emacs, so you can get started quickly and learn the more powerful features later.

Starting Emacs

To start Emacs type `emacs' and an optional file you wish to edit then press return. That's it!

Opening a file

If you didn't specify a file when you started Emacs you can open one after you enter Emacs by typing C-x C-f. This means hold down the control key and then press the x and f keys and release the control key. You will be prompted for a file name at the bottom of your Emacs screen. Enter the file name you wish to edit and press return.

Moving around in your file

There are three different ways to move around in your file: Control keys, the mouse and, if they are enabled, the arrows keys on your keyboard. Below are the control keys, with which you can move around in your file. Any other keys you press will be inserted as text in your file.

C-f forward-char
C-b backward-char
C-n next-line
C-p previous-line
C-a beginning-of-line
C-k kill-line
C-e end-of-line
C-d delete-char
C-g keyboard-quit
C-h help-command
C-l recenter
C-o open-line
C-r isearch-backward
C-s isearch-forward
C-t transpose-chars
C-v scroll-up
C-@ set-mark-command
C-w kill-region
C-y yank
C-z iconify-frame
C-_ undo

Saving and exiting

To save your file press C-x C-s

To exit Emacs press C-x C-c

Hints

If you get stuck by hitting the wrong key combinations you can press C-g to abort. This will terminated almost any command. You should read the section on getting help before you get started.

Command completion is a usefull time saving feature of Emacs and can save you many keystokes and works in most contexts. One usefull example is: when opening a file you don't have to enter the whole name, just type the first letter or first unique letters and then press the tab key. Emacs will fill in the rest for you. If there is more than one file with the same first characters, pressing the tab key again will open a buffer window with a list of the file names which have those first characters.

If you are using Emacs19, read the section on Emacs19 first. Many of the commands you do by entering keystrokes can be done using menus.

When you see M- in the documentaion it means press the ESC key first. On some systems the ALT key has the same effect.

To execute a command in Emacs use M-x and then the command name.

Buffers

When you edit a file in Emacs, it is stored and edited in a buffer and when you save your file you are actually saving a buffer. Buffers can not only contain files they can also be used for a wide variety of purposes. Among these is storing and displaying the information generated by help commands and utility lisp programs such as mail handlers or gnus, the Emacs news reader.

These are the most used buffer commands.

To list all the buffers use C-x C-b this is bound to the list-buffers command.

To kill a buffer use C-x k this is bound to the kill-buffer command.

Windows

Buffers in Emacs are displayed in windows. When you first start Emacs you see only one window, you can display more than one window by dividing the display either vertically or horizontally.

Use C-x 2 to split a window vertically or use C-x 5 to split a window horizontally.

Delete a window with C-x 0 and move to another window with C-x o.

Go to the previous, next section.