Why the old text editor “Emacs” is still in my toolbox

First version is from 1985 — software rarely survives that long!

Chances are you never heard of the text editor “Emacs” — especially if you started your career in this millennium.

Emacs icon (left) by Nicolas Petton, Logo (right) by Luis Fernandes (both Wikimedia Commons)

I ventured into programming at around the age of 10. This was in the mid eighties and I first dabbled in BASIC on a Commodore 128 and later got in pretty deep with Assembler on the Amiga. I had my first encounter with Unix and Emacs in 1995 as a computer science student. Post graduation, Emacs was certainly one of the first tools I installed as I went to the industry (and Windows). These days, Emacs is clearly outperformed by specialized IDEs such as Visual Studio and the old editor’s user interface looks like a dinosaur from my early programming days. Now, I prefer Visual Studio for C# and VS Code for anything else, but I frequently copy code to Emacs for more advanced edits when the other editors fall short. The main reason is Emacs’ SUPERIOR keyboard macro functionality, but other neat features have also not yet been picked up by other tools. Below is a short run-through of the features I still cherish in Emacs.

Editable keyboard macros

Most decent editors have macro functionality, but few (if any) offers the possibility to edit and recompile the macro if you made a mistake in a long complex recording. Emacs allows you to open the recorded macro as text, edit it, and recompile your changes. You can also get the macro code as lisp code and insert it into your Emacs config file.

Temporarily bind multiple macros to shortcut keys

Say you want to apply two different macros to the text depending on the contents below the cursor. It is easy to bind the last recorded macro to a key for the edit session. Thus, you record the macros one by one and then apply them using the assigned hotkey.

All commands are available in macros

This is pretty handy if you want to make the same complex change to multiple files. In Emacs, you just load in the files and record the macro with the save and close of the file as the last step. This brings the next file in focus on which you then execute the macro. Saving, switching between buffers, and closing files are rarely seen in other editors’ macro recording functionality.

Easy repeat of a keypress or macro

Emacs also has a no-fuzz way of repeating a keypress x number of times — just hold CTRL down while typing the number of repeats. Release CTRL and the next key will be repeated the desired number of times. This also works if you have assigned a recorded macro to a key. For example, pressing the following sequence: “CTRL down–1–0–0-CTRL up-F5” will simulate pressing F5 one hundred times and thus running the macro as I have assigned that to F5. Sure, other editors have something similar, but it typically involves opening a dialog, entering a number, and clicking ok.

Rectangular copy-paste

Normal copy-paste involves a selected block of text starting at some cursor position and ending at some other position perhaps a number of lines down. Hence, you are doing a “full-line” or “no-gap” copy. Emacs has a rectangular copy-paste feature where you can copy out a block of text, e.g., character position 5–42 of the first 19 lines that have varying line length. The copied block can then be pasted elsewhere. This is can be faster than recording keyboard macros if you want to do simple edits on multiple lines.

Easy switch to HEX mode

Working in a cross-OS environment with Unicode characters, I sometimes need to view text files as they appear on disk. For this, Emacs offers the hexl-mode, which is an immensely easy way to switch between HEX viewing and “rendered” text. This is particularly useful for spotting carriage-return characters and getting the unicode number for strangely rendered characters.

Conclusion

Emacs has more than 35 years of active duty under its belt. In my view, it has been passed by other IDEs when solely looking at the integration experience (writing code, debugging, running tests, looking at coverage, refactoring, etc). However, no other editor outcompetes Emacs’ keyboard macros. I’m a “automate-as-much-as-possible” programmer and I will probably keep it around for the next 35 years as well unless another editor surpasses its macros and the other features mentioned above.

Computer & data scientist, writer, thinker, photographer, and generally just curious about life and the wet matter between our ears

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store