Emacs is a powerful text and source code editor with many advantages

Featured image

Emacs is a powerful text and source code editor with many advantages, available in GUI and CLI since 1984. In this article, I will present the advantages of the software and I will teach you some essential basics to know in order to use it.

The advantages of the software

Free and cross-platform

Emacs is a free tool under the GPLv3 license that does not try to make you pay unlike other publishers. In addition, it is available on GNU/Linux, MacOS, Windows, Android with Termux, FreeBSD, NetBSD, OpenBSD and Solaris! So you can try it regardless of your operating system.

Available in GUI and CLI versions

Emacs can work in Graphical User Interface and Command Line Interface. If you are not used to typing commands into a shell/cmd I recommend the graphical version. The latter has the advantage of allowing the display of images, mouse use and letting the user navigate on a menu with a toolbar.

Lightweight and modular

Emacs is extremely lightweight and consumes few resources. The software was originally designed to process text in a terminal. Therefore, the latter works on both modern and older machines.

In addition, Emacs offers optional IDE features that are interesting for those who want to use its full potential. The software allows to manage projects with many modules such as org mode, generate code, quickly find function declarations, etc….

The possibility to only use a keyboard

With Emacs, it is possible to use only your keyboard for either the CLI (obviously) or GUI version. The use of the mouse is therefore not mandatory and without even raising your hands from your keyboard, you can do anything! In addition, the editor’s default shortcuts have all been created to optimize order entry speed. For example, dedicated keyboard keys, such as Home, End, and arrow keys are all replaced by the ctrl and alt/shift keys on the keyboard. For more information on basic shortcuts, take a look at the table at the end of this article.

Useful proposals that vary according to the context

In addition to text manipulation functions, Emacs provides functions depending on the context in which it is used. For example, if you code Python, the software will ask you to start the Python interpreter in order to execute your script / program. If you write an email, the software may offer you to add fields to it or even attachments. The editor can be easily configured to satisfy any user. I also offer you my configuration on the HackDown Wiki.

Tutorial included

Emacs includes a tutorial available in several languages to help beginners familiarize themselves with all its commands and shortcuts. This tutorial is accessible from the home buffer and explains how to manipulate the text, structure the software, import modes and windows, etc…

Kill-ring and Mark-ring

The Emacs clipboard has a great advantage: it keeps all entries in memory. When text is placed there, what was previously there is not lost. So, when you paste the contents of the clipboard, you can select the element you want to paste from all those that have been pasted. By default, the most recent one will be displayed.

For example, if I have the text “old message” in the clipboard and I put the text “new message” there. When I paste the contents of the clipboard, I get “new message”. With a simple keyboard shortcut, I can replace this text with “old message”. I can thus go back to the history of the clipboard. In this history, the end is connected to the beginning, forming a ring. Hence the name “kill-ring”.

The Emacs editor also allows you to place markers within the manipulated text. The cursor can then easily be moved from one marker to another. This feature is very useful when you wants to come back to a piece of code later. Again, the history of the markers forms a ring, hence the name “mark-ring”.

Macro keyboard

Emacs also supports macros: you can record what you type in order to quickly repeat the text/commands you entered in the editor. It is also possible to specify the number of of repetitions of your macro. When recording a macro, a counter can be inserted in the text. You can also give this macro a name to call it as an interactive function and save it so that it survives the session. Of course, you can also edit your macro in another session!

Automatic closing and highlighting of delimiters

Emacs can automatically close parentheses / quotation marks. For example, if I type ", the editor will ask me to close the string with a " closing. If I select a region and type a quotation mark or parenthesis, Emacs will surround that region with the chosen character. And if I place the keyboard cursor next to a parenthesis (or quotation mark), then its corresponding parenthesis (or quotation mark) will be highlighted.

The foundations of Emacs

Essential shortcuts

Here is a table showing the commands essential to the use of the software (Ctrl+C and Alt+M):

Shortcut C-x C-c C-x C-g C-v M-v C-l C-b M-b C-f M-f C-n C-p
Function Quit Emacs Cancel partially entered command Move one screen forward Move one screen backward Middle of page / End of page / Beginning of page (stays on same line) Move one character backward Move one word backward Move one character forward Move one word forward Next line Previous Line


Written by Luka