Microsoft Store
 

Emacs


 

:This article is about the text editor. For the Apple Macintosh computer model, see eMac.

Using Emacs

Commands

From the Unix shell, a file can be opened for editing by typing "emacs ". If the filename you entered does not exist a file will be created with that name. For example "emacs xorg.conf" will edit the xorg.conf file in the current directory, if it exists. However, Emacs documentation recommends starting Emacs without a file name, to avoid the bad habit of starting a separate Emacs for each file you edit. Visiting all files in a single Emacs process is the way to get the full benefit of Emacs.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In the normal editing mode, Emacs behaves just like other text editors: the character keys (a, b, c, 1, 2, 3, etc.) insert the corresponding characters, the arrow keys move the editing point, backspace deletes text, and so forth. Other commands are invoked with modified keystrokes, pressing the control key and/or the meta key/alt key in conjunction with a regular key. Every editing command is actually a call to a function in the Emacs Lisp environment. Even a command as simple as typing a to insert the character a involves calling a function?in this case, self-insert-command.

Related Topics:
Backspace - Modified keystrokes - Control key - Meta key - Alt key

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Some of the basic commands are shown below. The control key is denoted by a capital C, and the meta or alt key by a capital M.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Note that the commands save-buffer and save-buffers-kill-emacs use multiple modified keystrokes. For example, C-x C-c means: while holding down the control key, press x; then, while holding down the control key, press c. This technique, allowing more commands to be bound to the keyboard than with the use of single keystrokes alone, was popularized by Emacs, which got it from TECMAC, one of the TECO macro collections that immediately preceded Emacs. It has since made its way into modern code editors like Visual Studio.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

When Emacs is running a graphical interface, many commands can be invoked from the menubar or toolbar instead of using the keyboard. However, many experienced Emacs users prefer to use the keyboard because it is faster and more convenient once the necessary keystrokes have been memorized.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Some Emacs commands work by invoking an external program (such as ispell for spell-checking or gcc for program compilation), parsing the program's output, and displaying the result in Emacs.

Related Topics:
Ispell - Gcc

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The minibuffer

The minibuffer, normally the bottommost line, is where Emacs requests information.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Text to target in a search, the name of a file to read or save, and similar information

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

is entered in the minibuffer. Tab completion is always available in the minibuffer.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

File management and display

Emacs keeps text in objects called buffers. The user can create new buffers and dismiss unwanted ones, and several buffers can exist at the same time. Most buffers contain text loaded from text files, which the user can edit and save back to disk. Buffers are also used to store temporary text, such as the documentation strings displayed by the help library.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In both text terminal and graphical modes, Emacs is able to split the editing area into separate sections (referred to since 1975 as "windows", which can be confusing on systems that have another concept of "windows" as well), so that more than one buffer can be displayed at a time. This has many uses. For example, one section can be used to display the source code of a program, while another displays the results from compiling the program. In graphical environments, Emacs can also launch multiple graphical-environment windows, known as "frames" in the context of Emacs.

Related Topics:
Source code - Graphical-environment windows

~ ~ ~ ~ ~ ~ ~ ~ ~ ~