Navigating the Text Editor Holy Wars

Morgan Martin
Jul 25, 2016 · 8 min read
Image for post
Image for post
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?

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

Image for post
Image for post

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

Image for post
Image for post

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

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.

Image for post
Image for post
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

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!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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