paint-brush
8 Reasons Why Emacs is the Best Text Editor for Programmingby@Alex_Wulff
10,821 reads
10,821 reads

8 Reasons Why Emacs is the Best Text Editor for Programming

by Alex WulffJuly 28th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

If you're reading this article, chances are you regularly use Notepad, Visual Studio, or Sublime to write code and edit text. Here's why you should use a command line text editor that you can use to accomplish practically any development-related task. Many of the benefits outlined in this article likely apply to other command line editors as well. However, I also detail many Emacs-specific features that I feel make it the top choice for developing software. For example, you can easily install it on every system I know of, such as the Raspberry Pi Zero.

Company Mentioned

Mention Thumbnail
featured image - 8 Reasons Why Emacs is the Best Text Editor for Programming
Alex Wulff HackerNoon profile picture

If you're reading this article, chances are you regularly use Notepad, Visual Studio, or Sublime to write code and edit text. Here's why you should use Emacs instead.


Emacs is a command line text editor that you can use to accomplish practically any development-related task. If you're not already familiar with command line editors, they are programs that run entirely within a terminal window. They share much of the same functionality as traditional text editors and IDEs, but offer significant portability and customization benefits that other editors do not.


There are many other command line editors, such as Vim or Nano, and many of the benefits of Emacs outlined in this article likely apply to other command line editors as well. However, I also detail many Emacs-specific features that I feel make it the top choice.


Calling Emacs a text editor is a little like calling your iPhone a telephone. Making calls might be a primary intended function, but that's by no means all it's designed to do. In the same way with Emacs, editing text is certainly its primary function, but a whole host of other features mean that you hardly ever need to leave Emacs while developing. Below I'll outline what I love about using Emacs and why I think you'll love it too.

1. Emacs is Fast

If you take the time to learn Emacs, its speed is unparalleled in all senses of the word. Once its navigation commands are baked into muscle memory, your cursor practically moves on its own. Routine editing tasks are a breeze, almost every development tool you could desire is right where you need it, and there are is no discernible lag or hangup in any part of the program.


Emacs, like other command line editors, relies solely on keyboard input for navigating around files, performing macros, and any other feature you'd want your development environment to handle. Your fingers can stay on the keyboard while typing which vastly increases your productivity and speed. You spend less time getting your cursor to where it needs to be or interacting with buttons/menus and more time actually editing and building things.

2. Emacs is Extremely Customizable

It's very difficult to capture in words the extent to which Emacs can be customized. I don't just mean the superficial customization available in other text editors, such as changing themes or keyboard shortcuts. Emacs itself is practically an operating system, and you can configure it to handle any possible workflow you can imagine.


Relatively simple tasks, such as integrating debuggers directly into the editor, automatically compiling LaTeX, or accessing documentation are either already baked into Emacs or available as a third-party package. More complicated tasks are possible with a few lines of Emacs Lisp, a programming language you can use to add to the functionality of Emacs itself. Emacs is entirely open source, and you're free to extend it as you see fit.


If this all sounds confusing, don't worry. Emacs' basic functionality is easy to master, and there's a practically infinite well of additional functionality waiting for you as you become ready for it.

3. Emacs is Available Everywhere

This statement is true of other command-line editors, but it's an important point to note nonetheless. If you spend a lot of time working on servers, playing around with Raspberry Pis, or generally performing development on other machines, learning a command line editor is a must.


Emacs can be easily installed on every system I know of. It can also be used over SSH, so you can use it to edit files and develop on remote machines. Additionally, you store practically all of the customization you do to Emacs in one text file. When developing on a new machine, you can copy this file over and be up and running with all your customizations in seconds. This portability and consistency is so good that I sometimes forget that I'm using Emacs on a remote machine over SSH and try to access files or programs available only on my local machine.


Emacs certainly has more functionality than other command line editors, but it's still lightweight enough to easily run on resource-constrained systems like the Raspberry Pi Zero. Wherever you need Emacs, it's there.

4. Emacs is (Arguably) Easy to Learn

If you use your mouse a lot while editing, you may find transitioning to Emacs a little jarring. Rather than using your mouse to move the cursor around and navigate between files or shell prompts, you instead use keyboard commands.


Emacs makes this transition relatively easy for new users. You can start in Emacs by using the arrow keys to jump between lines and characters. You can then learn the keyboard navigation commands one at a time, and slowly transition away from the arrow keys to only keyboard commands. This is a lot faster than using the arrow keys, as your hands can stay in the same place on the keyboard and there are dedicated commands to jump over large groups of characters or lines.


Emacs' text selection and copy/paste work this way too. You can still use your mouse to select/copy text, and you can slowly learn how to use Emacs' text marks and kill ring to move text around at a much faster pace.

5. Emacs Commands are Baked Into Unix

If you use macOS, many basic Emacs commands are actually baked into the operating system itself. This means that you can use Emacs' navigation commands to move around in practically any text box in your operating system.


This is an extremely underrated feature that only Emacs offers. This prevents so-called "muscle-memory impedance mismatch," where you try and use shortcuts or commands from one program or system only to find that they don't work in another program or system. It's an extremely frustrating experience and prevents you from fully committing to using certain features. With Emacs, this isn't an issue, and the interoperability of commands only helps reinforce what you're learning.


You can actually try this out right now. If you're on Linux, open up a terminal window. On macOS, practically any text box should work (for example, the search field in Safari, the Spotlight text window, TextEdit, Notes, etc). Type a few words, and then press Control-a. This is the command to move the cursor to the beginning of a line. Press Control-e, and the cursor should move to the end of the line. Go back to the beginning of the line, and press Control-k. This should "kill" the line and make it disappear. Control-y will "yank" the text back into existence. These are just a few of the commands you can use!

6. Shell Buffers (and Python, MATLAB, etc)

Emacs has a robust "buffer" (the equivalent of the window) management system that you can use to have multiple files open in all sorts of configurations. Inside an Emacs buffer, you can even have a shell prompt running. This means that you practically never need to exit Emacs during a development session, as all the tools you could need are right there. In addition to a shell prompt, you can have a Python terminal, a MATLAB prompt, and many others.


All the standard Emacs commands will work, and Emacs even has special commands that make development a breeze. This includes features like selecting blocks of code and running them in a shell buffer, debugging with gdb right insight Emacs, and much more.

7. Emacs is Old

The first public release of Emacs was in 1985, making it older than many programmers today. This may seem like a bad thing, but it has given the Emacs community nearly 40 years to make it as perfect as it can be. Emacs' age should also give you some assurances of its longevity.


In this 40-year timespan, generations of developers have extended Emacs' functionality, ported it to every major operating system, and continue to maintain a standard of excellence and stability that Emacs is known for.

8. Emacs has Fun Easter Eggs

Over its long life, developers have added some extremely amusing programs that ship within Emacs. Some could argue that this makes the program unnecessarily bloated, but I find this type of thing fun and I'm sad to see it go by the wayside in favor of professionalism in modern programs. Below are a few of my favorites.

Dunnet

Dunnet is a fully-fleged text-based adventure game built right into Emacs. The game is actually very fun and engaging, and I highly recommend playing it even if you have no interest in Emacs.

Classic Games

Emacs has classic video games like Snake, Tetris, and 2048 that can help decrease your productivity.

Doctor

Emacs can psychoanalyze your problems.

Game of Life

You can also kill time with the built-in simulator for John Conway's Game of Life.


There are, of course, many other reasons to use Emacs. I hope the reasons I gave are compelling. If you already use Emacs, let me know what I'm missing or what your favorite features are. If this convinced you to switch, I'd also love to hear about it!


Check out more of my writing on my website www.AlexWulff.com.


Also published on: https://towardsdatascience.com/eight-reasons-why-emacs-is-better-than-your-current-text-editor-7ae0d4e03f02