Navigating the Text Editor Holy Wars

Morgan Martin
8 min readJul 25, 2016

--

Thanks to XKCD for the image

You might have heard of the rivalry between Vim and Emacs described in such reverent tones before, but never understood why or how so many people could display so much passion about a text editor. So if you’re looking for the answer, but you don’t have the time to make the traditional trek to the top of a forgotten Himalayan mountain to train under the zen guru (it was fairly anticlimactic anyway) then you’re in luck, because this post is the No Bullshit Guide to Navigating the Text Editor Holy Wars.

What’s a Text Editor, anyway? What about an IDE?

On the one hand you have your text editors; Notepad++, Vi, Vim, Emacs and the like. These are often called “plain text editors” because they, well, edit plain text. Then you’ve got your IDE’s; IntelliJ, Eclipse, CodeLite, and NetBeans. Most of the time, IDE’s are specific to one or perhaps a handful of languages. Out of the box, they have features like build automation, code completion and even compilers/interpreters. They may even have class hierarchy diagram features. There are two major differences between IDE’s and text editors. The first is that IDE’s tend to “point-and-click” by default. They embrace the mouse and do so shamelessly, whereas text editors ( or at least the popular ones) despise it. The second is that they lack community . Most of the time (there are exceptions, thought not many) IDE’s are sold as products. The popular text editors are open source. Where you will find the touch of cold, calculated corporate-ville in IDE’s, you find history and community in text editors. I will expel with the words of ethos since this is the No-Bullshit Guide, but you should know that there is some amount of community inherent with the text editors.

So what should your takeaway from all of this be? If you’re happy with the way your workflow operates currently and are not interested in streamlining for efficiency, then you’ll be fine with an IDE or “point-and-click” editor like Sublime. If, however, you are interested in increasing the efficiency of a task that you could potentially be doing for decades, then read on.

Vim and the Concept of Modal Editing

If you run a Unix system, odds are you’ve found yourself in an unfamiliar, black and white editor that doesn’t respond to the usual point and click commands that most other programs do. This program is called Vi. Vi, its predecessor Ex and Vi’s successor Vim are all modal editors i.e. they have different modes. If you’ve ever taken the first small leap whilst inside of that unfamiliar editor, you probably know that pressing the “i” key will put you into an insert mode that then allows you to start typing as usual. You may not have known it then, but you were experiencing modal editing.

Vim has six(?) different modes, but only three of them are used often enough to be of note; Normal mode, Insert mode and Visual mode. The concept of modal editing is simple. Normal mode presides over the lion’s share of functionality. Navigation and much of the text manipulation functionality reside in this mode. Next there is insert mode, the yang to the yin of normal mode. While you can get away with using normal mode for many things, it is never enough. Eventually, you must enter insert mode and start typing. Visual mode is also very powerful, but I will leave it to others for a more in depth explanation.

The key insight is the speed inherent in modal editing. If you want to duplicate a line or paragraph or method in a point-and-click editor, you must take one of your hands off your keyboard, place it on the mouse, use some fairly fine motor skills to navigate the cursor from the beginning of a line to the end, right click, select copy, and start the whole process over to navigate to wherever it is that you want to paste to. In Vim, you simply press “yy” to copy the entire line (or “yip” for a paragraph), “j” or “k” a few times to the line you’d like to paste at, and then finally “p” to actually paste. The process is much faster, and much less prone to error, something we humans are notorious for.

It is worth noting that Vim also uses something very similar to grammar for text manipulation. “dw” deletes a word. “p” pastes. “cw” changes a word, by first deleting it then placing you in insert mode, ready to change it. “u” undoes a change, and “D” deletes to the end of the line. It might seem like an exaggeration to describe these features as grammar, but it becomes quite apparent that this is an accurate representation if you spend any time with Vim. Essentially, you don’t need to remember a unique key sequence to every action you might take. Instead, you must learn the constituent parts of the action you are trying to describe, and then your intuition takes over. No particular resource explicitly taught me that “di{“ would delete inside of curly braces; I just know it because it’s in line with the way the rest of Vim works. The grammar is a bit more expansive than can be explained in a mere paragraph, but with the right instruction, one can pick it up in a week.

It is difficult to overstate just how important this idea of not removing your hands from the keyboard is. While increased speed is inevitable, it also takes time to acquire. However, the lack of “context switching” from “typing-mode” to “point-and-click-mode” results in a non-trivial decrease in cognitive load, something incredibly important to anyone who considers themselves part of the “knowledge economy.”

The Emacs Operating System

Emacs is not, of course, an operating system. However, it has certainly been described that way by many! This joke is based somewhat in reality. Emacs has everything, including the kitchen sink.

The power of Emacs lies in its propensity for extensibility. Anyone with the desire and a little bit of free time can customize and extend Emacs to their heart’s content, thanks to the language it is written in, EmacsLisp. Lisp is a whole other can of worms, but suffice to say that it’s awesome.

It is worth noting that Emacs is incredibly old by software standards, 40 years, in fact. This longevity has been no accident. Emacs has lived and prospered for so long for one reason. Community. Emacs is open source software, and it is one of the movement’s most beloved creations.

So what makes it so awesome? As noted before, Emacs is all about extensibility. If you can think of a plugin that might have something to do with a text editor, it’s already been added to Emacs. Git integration, code completion, linters, keyboard shortcuts, project layouts, fast project navigation, web browsers, organizational tools, pdf viewers, games, even spotify navigation. It really does have everything! It should be apparent why some people describe it as an operating system now.

With all of this, you might be surprised by the one thing that it lacks; sensible defaults. Detractors often say, “Emacs has everything, except a decent text editor.” And this is true, kind of. Thanks to its extensibility, you can add the decent text editor bit. As for why this isn’t done up front, I believe the answer has something to do with many influential members of the community being used to the old way, and so this influence propagates. At the end of the day, this minor blemish does not make Emacs any less capable. And because of this capability, I (and many others) name Emacs as the winner of the Great Editor Holy Wars. With one major caveat. Vim also wins.

Spacemacs

What if you could marry the clear superiority of Vim’s modal editing with the extensibility of Emacs? Well it turns out we are not the first to ask the question. And it also turns out that it has already been answered.

EVIL (Extensible Vi Layer) mode for Emacs, is a “plugin” for Emacs. It does exactly what you would hope it to. It brings Vim controls to the Emacs environment. Look no further young apprentice, for the answer to the question of what the best text editor is has been answered. It is Vim inside Emacs.

So, you might be asking, if EVIL mode is the answer then why is this section of the guide labeled “Spacemacs?” That’s because I use Spacemacs and I think it is the logical conclusion to all of this text editor hullaballoo.

Here is how Spacemacs describes itself on its website: “Advanced Emacs kit focused on Evil.” Basically Spacemacs is an Emacs configuration that adheres to the true “everything and the kitchen sink” philosophy that Emacs is known for, except it applies it to super quick and efficient modal editing. Anyone coming from the world of Vim will likely be familiar with the concept of the leader key. Basically it is a key common to many different keyboard shortcuts for common tasks. Spacemacs is centered around this concept of a leader key, using the spacebar as its home base, thus the name Spacemacs.

Spacemacs has way too many features out of the box for me to possibly go over here. The picture below is a screenshot of what happens when you press the spacebar.

The Gloriousness that is Spacemacs

Notice the “terminal” of sorts at the bottom of the image. Each character there describes a keyboard “path” that you can take. If I would like to save my file, I simply type “space-f-s” i.e. “space-files-save.” This is an incredibly vanilla use case of the leader key. There is so much more that it can accomplish with the use of a few keys, but is quite difficult to explain these features to someone without the context to understand them in. Suffice to say that any task central to text editing or programming in general that you repeat throughout a typical day is only ever, at most, 4 keystrokes away.

Conclusions and Caveats

Many who read this article will not agree with my conclusion that Spacemacs is the best option, and that is fine. It is of course not the best choice in all circumstances. If you ssh into other computers often, then you’ll probably prefer to keep a .vimrc file handy, rather than the comparatively huge Emacs distribution. Perhaps you agree that Emacs is the way to go, but you prefer RSI and key chords. Or maybe you thought I oversimplified the differences between IDE’s and text editors (I did.) That’s all fine. I can only offer up my attempt at an objective opinion, and a little anecdotal evidence suggesting improvements between my workflow with Sublime and Spacemacs.

Even if you think I hold some bias, if you take nothing else from this article, then take this small piece of advice: It costs nothing to try out Vim or Emacs or Spacemacs. They are not nearly as hard to learn as they are made out to be, and it’s actually really fun to increase the efficiency of your workflow! Whatever you do, I hope that this article/guide shed a little light on the craziness that is the Text Editor Holy Wars and that you will go forth and prosper in all your coding adventures!

--

--