﻿ Emacs: The programmer's editor | FreeOS, free operating systems
Pick a Free OS

User login


Emacs: The programmer's editor

The command to save a file is Ctrl-X S. Emacs saves the contents of the modified file in memory to disk. In effect, emacs only does a buffer write. The rest of the buffers that can be holding contents of other files are not updated on disk. To save the file under some other name use the 'Save As' command which is given as Ctrl-X W. After issuing this command, emacs will you to specify the new name for the current file.

Quitting emacs

To quit emacs, the command usually given is Ctrl-X C. This command finishes the current emacs session and returns you to the shell prompt. If files opened in their respective buffers have not been saved, emacs gives a prompt for each file asking the user whether he/she wishes to save the file. You can also suspend emacs operation so that it temporarily spawns a shell where you can issue commands to the operating system. Issuing the Ctrl Z command can do this. You can return to emacs by typing 'fg' at the command prompt.

Given below are some basic commands to help you start off.

* Cursor movement keys

Ctrl A beginning of the line.

Ctrl E end of the line.

Alt A beginning of the sentence

Ctrl P previous line.

Ctrl N next line.

Ctrl B one position to the left.

Ctrl F one position to the right.

Alt F one word to the right.

Alt B one word to the left.

Alt < beginning of file.

Alt > end of file.

* Scrolling screens

Ctrl V Scrolls forward by one screen.

Alt V Scrolls backward by one screen.

Sometimes, it may so happen that the text display gets garbled due to unwanted kernel messages or 'wall's (write alls) from other users. Issuing the command Ctrl-L can set the screen right.


In case you have opened multiple files in emacs, you need different buffers to store them as one buffer can hold only one file. At any time, only one buffer is active. To switch to another buffer, we can issue the command Ctrl B, where denotes the name of the file opened in the other buffer. Whenever a file is opened and loaded in a buffer by emacs, the buffer gets the name of the file. Thus, you can assume the buffer name to be the same as the filename.

Delete operations

The following `delete’ operations can be performed.