Editor Wars

As a rule, I try hard not to get sucked into religious wars. You know, Coke vs Pepsi. C++ vs Java. Chrome vs Firefox. There are two I can’t help but jump into: PC vs Mac (although, now that Mac has turned into Unix, that’s almost more habit than anything else) and–the big one–Emacs vs vi.

If you use Linux, Unix, or anything similar, you are probably at least aware of the violence surrounding this argument. Windows users aren’t immune, although fewer of them know the details. If you aren’t familiar with these two programs, they are–in a way–text editors. However, that’s like calling a shopping mall “a store.” Technically, that’s correct, but the connotation is all wrong.

Like most religious wars, this one is partly based on history that might not be as relevant as it used to be. Full disclosure: I’m firmly in the Emacs camp. Many of my friends are fans of vi–I try not to hold it against them. I’ll try to be balanced and fair in my discussion, unless I’m talking about my preference. I don’t have to be fair when it comes to my opinions. Just to be clear: I know how to use vi. My preference isn’t based out of not wanting to learn something new.

The Big Differences

Superficially, there is one big difference between the two editors. Vi has the concept of a mode. Most commands are just ordinary letters (for example, the I key enters insert mode). The problem with that, of course, is that if you start typing in the wrong mode you either get command characters in your file or you issue lots of random commands.

Emacs works more like a normal text editor. When you type normal characters they go into the current file. Commands use special prefix characters like Control+X or Escape. Sure, you might have a normal letter after a prefix (Control+X C, for example) but that’s only for the short duration of the command.

The Case for Vi

The best argument, in my opinion, for vi is that it is fairly lean and it is on just about every Unix-like system you’ll ever encounter. There are other “standard” editors, but they are not screen-oriented and are very painful to use. That’s why I know how to use vi.

You’ll often hear the argument that vi is lean and Emacs is bloated. That’s somewhat true, although modern versions of vi (like vim) are not very skinny, either. Generally, vi starts faster than Emacs, all other things being equal (although you can bog down either one). However, there’s a reason for that, as you’ll see in a minute.

The Case for Emacs

If it were just the fact that Emacs always lets you type plain text, it really would be just a matter of personal preference. However, I have noticed that there are two things people who are passionate about Emacs have in common. First, they are people who either predate widespread use of X11, or that could not use it for one reason or another. Second–and this is a secondary effect–they tend to be touch typists.

The first reason is because Emacs is a text-based window manager. Sure, the most common thing to have in a “window” is a text editor, but Emacs can also display file managers, games, e-mail clients, web browsers, and plenty of other window types. You can even run a shell inside an Emacs window. The most recent version even has a WebKit-based browser. You can watch a YouTube video from within Emacs. If YouTube doesn’t excite you, maybe you’d be more impressed by opening GitHub, Google, or Hackaday.

This leads to the popularity, I think, among touch typists. Being able to create, manipulate, and switch windows without taking your hands off the keyboard is very valuable to fast typists.

Granted, today, you don’t need a text-based windows manager. You could use GNU screen, although it works a little different. But most of us use a GUI desktop now and it is less important to have Emacs manage windows for shells, browsers, and so forth. Even if you want keyboard-driven window management, there are solutions for that too.

If you are a hardcore hacker, Emacs has one other advantage: it is fully programmable using a version of LISP. That’s a dual-edged sword. On one hand, Emacs an do anything. On the other hand, you can go deep down the rabbit hole making custom set ups.

So What’s the Answer?

So maybe it really is a matter of personal preference. But to me, its still Emacs all the way. One thing I’ll point out: It is pretty easy to make Emacs act very much like vi, but the reverse isn’t possible in any meaningful way. Of course, if you are under a certain age, you probably use some GUI editor like sublime or Eclipse and are scratching your head that an editor war even has its own Wikipedia page (not to mention the flurry of comments this post will probably launch).

If you do log into an embedded Linux system that doesn’t have enough horsepower (or connection bandwidth) to support a GUI, both of these editors can help you be more productive. However, Emacs can also give you some measure of multitasking windowing, even over a non-GUI SSH or telnet connection.

177 thoughts on “Editor Wars

  1. I use nano when I want to edit text, because editing text is what it does, not much more, and that is what I want.
    Vi or Emacs can do a lot more, yes, but in the realm of just editing text, most of it is just bloat, if I want to do more than text editing it might really come in handy, but that’s not the realm of a text editor to me.
    And no cat isn’t a text editor, it’s a string inserter.

  2. After reading the article and comments I have only one question: why would anyone sane in 2016 use a text editor to watch Youtube?
    Whenever I have to do anything with Linux, I use Nano. I never touched Vi or EMACS, and I hope I never will. For programming I have IDEs, for text files I have Notepad, ed or Nano, for writing anything else I have OpenOffice…

  3. My first editor was pencil and paper:
    Our Wang didn’t have any mass storage, so you had to type it in each time you wanted to work on it.
    I used an IBM 029 Keypunch machine and Hollerith cards for a 360/33 and 360/44. Very tactile and intuitive.
    Then edit on TOPS-20, edit: son of son of stopgap. It was a powerful line editor.

    I have a warm place in my heart for TECO. The joke was that TECO was for people who could remember
    what they were working on, but the stream-of-consciousness way that you used it for entering code was
    unique.

    That all changed when we got two tapes from Columbia, with emacs on it. Oh. my.
    Epsilon (a good fast emacs for the PC), and Gosling’s emacs on Sun workstations ensured that I was never without it,
    and when djgpp came along, suddenly I had a real emacs on a 486. The ports and integrations of Emacs on
    Windows machines are admirably good now. The version that runs on an android table is rather less satisfying, for now.

  4. All this is pretty funny, the main thing I got out of all this is that there is some other editor named nano that I could consider looking at. I have been using vi since before emacs was an option, so at this point my advice is to use whatever you are already used to. A good trick to play on someone is to tell them to start emacs and then try to figure out how to get out of it, but that is probably true of any editor. Vim serves me well though and if I wasn’t so busy working on all these projects I might try to learn more about vim (since I am an old “vi” dude and haven’t learned all the new tricks) and/or look at nano, but at this point vi is deeply wired into my muscle memory. Maybe nano is the best recommendation for a new hacker though???

    And yes, I actually used to use “ed” on unix (edition 7), but abandoned it immediately when I discovered vi. I can do it, but why waste my time and create needless errors. Brain cells are better spent writing code than keeping track of things an editor can keep track of for you (i.e. any editor that makes you deal with line numbers is brain damaged).

    1. I don’t know who these spacemacs folks are, but having done 2 minutes of in-depth research, it sure seems like “we’d like to write some code and re-invent the wheel”. Most of their features don’t seem new to emacs users (especially when you factor in various vi-emulation modes that emacs has had over the last couple of decades).

      1. It’s not about re-inventing the wheel. If anything, I see the main benefit of Spacemacs is an Emacs that’s easier to navigate around (for people who are new to Emacs). Perhaps it’s easier to see the benefits by trying it out?

  5. I rather enjoyed this article. It seems particularly surreal to me that Emacs won as an “editor” based on its skills as a window manager.

    Superficially, vi has “modes”, but anyone who takes just a moment to think about it realizes that Emacs has modes also–in fact many more of them. In vi you have insert, visual and ex mode. You get in and out of them in different ways, but they do different things so it’s okay. In Emacs you start out in a sort of nothing mode, which is somewhat like vi’s insert mode, and then add to it control+ mode, meta+ mode, C-x-mode, M-x-mode, C-c-mode, and probably another dozen more. The first two return you to insert mode just by releasing the modifier key, but the others require something else. It’s odd, really.

    The real difference between the two, when taken as editors and not window managers, is that in Emacs the commands are stand-alone instructions, whereas in vi the commands are composeable units of functionality. This means that the same cursor movement keys can be used to provide a selection range, or a deletion range, or a replacement range. Vi also has selection ranges for “a word”, “a line”, “a paragraph” and “a block” which are a tiny bit of effort to learn, but so much more often what you really want. They are dramatically better than “navigate tediously to the beginning of a block, set the mark, navigate tediously to the end of the block, cut”…

    The “hjkl” thing is just noise, really, because there is almost always a more efficient way to get where you’re going than that. It is almost always quicker to search than it is to go down, down, down, down, down, down, down, up, right, right, right, right. :)

  6. VI is most convenient if you also use it as your command line editor. As a data center admin the first command I run when logging into an unfamiliar machine is “set -o vi”, regardless of whatever UNIX/Linux flavor. This immediately gives me the ability to browse and edit the command history via “esc k”. Then “hjkl” movement comes into play. “j and k” to move up and down through the history, “h and l” to move left and right on the line. Edits are quick and precise. Need to change a single character on the line? Move the cursor to that character press “r” and replace a single character. Want to change a single word? “cw” will do that.

    1. I used to do something like that, but I spelled it differently: set -o emacs

      :-)

      For some reason, I don’t have to do that any more. I guess whoever defaults such things defaults to the emacs bindings these days. I don’t know the story of how that came about. In the original Korn shell, we had the choice of “emacs”, “gmacs”, or “vi”. Although ksh had no default, on every system I used, someone had set the default to “vi”.

  7. The only point well put here was that emacs is a windows manager. Everything else is highly… unenlightened. The fact that you are comparing emacs to vi is the biggest tipoff to this. Nobody uses vi unless they are crazy or that is all they have access to. Vim is much better. And I think Neovim is even better. If you don’t know, Neovim is not some new GUI version of Vim, it is a fork of it. They refactored / cleaned up the code, removed some really outdated stuff, got it running faster, and added new features. It is quite stable and mostly works with all Vim plugins, I have had no issues with stability or plugin support. They provide a ppa to install it on Ubuntu and instructions for other system. My point of all that is it should be considered a valid thing to compare to emacs when discussing this “holy war”, but that vi is not, as it is highly crippled compared to the other 2 options (Vim and Neovim). It would be more fair to compare emacs to just Vim, and by Vim, I mean both Vim and Neovim, since I consider Neovim to be a Vim. Neovim also comes with better default settings, so it is easier to get started with overall despite that you have to install it. If having to install it is enough of a deterrent, you are not the right person to evaluate which one is better. Anything that gives you great power will require an investment of time and learning to get really powerful with it. Neovim also gives you better access to more languages that you can use to write asyncrounous customizations or plugins for your Neovim. Actually you can use any language you want for this if you communicate with the API offered by Neovim. Actually you could also use this API to fully integrate Neovim into other editors or IDES, including emacs, instead of just adding a Vim emulator. I am developing a Neovim plugin using Node.js at the moment.

    It is true that the main difference between Vim and Emacs is modes. Modes are the hardest thing to really get and like and prefer in Vim. It takes a while. But once you get there, once you see the light, you will always prefer a modal editor. You will never go back. Modes are why Vim is better than Emacs. I will try to explain this, but it is better to experience it for yourself.

    The lack of modes in Emacs makes it give you carpel tunnel syndrome. I am partly joking, but it is true that I get very little wrist pain now that I mostly program in Vim. Imagine this for power. Every key on the keyboard is a special feature. That is the power of normal mode. Vim power for the win. It may sound impractical. How could you really memorize all those things. Trust me, the ones you use a log, they will become muscle memory. And you will get better and better at looking up what the others are / do over time. The main advantage of modes is they fit into the philosophy of keeping your fingers close to the home row, and working fast. Many commonly used normal mode mappings are just single keys close to the home row. If you do need to press multiple keys, you don’t need to contort your hand and press multiple keys at the same time. You just press one, then the other, etc. Not having to press multiple at the same time and keeping you fingers close to the home row is why using Vim is less painful and less damaging to your body.

    There is one thing about Vim that you should customize in order to make working with modes less frustrating. You have to press escape to back into normal mode. On most keyboards, the escape key is very awkwardly placed. It no longer fits into the painless, flowing, close to the home row, philosophy of Vim. Personally, I mapped kk to bring me back into normal mode. Do a google search for all the ins and outs and tips for accomplishing that. k is the key I press with my right middle finger, which makes k the easiest key on the entire keyboard for me to press. This does get a little annoying when you actually need to type a k. It will kind of hang, waiting to see if you will press it again before it looks ready to accept more characters. But it is ready just keep typing. If you just want to type a single k and then go back to normal mode, type k and then some random character, go into normal mode, and then delete that character. It sounds really annoying, but once you get used to it, it is really not that bad, and is the price you pay to get such a nice normal mode mapping. A good alternative is to customize your system so that the caps lock key gets registered as escape. You don’t really need the caps lock key do you? I mean there are more times you activated it by accident and got annoyed than times that you used it intentionally and got good results from it right? On most keyboards the caps lock key is much more natural to press than the escape key. Actually I do both of these (caps lock is escape and kk goes back to normal mode). Having an alternative to the escape key is essential because you will need it often enough in Vim even if you don’t use it to go back to normal mode. The only reason I use both of these techniques together is when I use the prompt app on iOS to connect to a server use Vim with my apple bluetooth, keyboard, the escape key is vary awkwardly placed, and I can’t make any other keys register as escape.

    Use 50% of your programming time improving yourself and your tools. This is how you will get the most productivity over time, and it is how you will get the most out of Vim. Look for ways to improve / optimize your workflow inside of Vim. You can find or make any tool you want (rafactoring tools, code generation tools, compilers, transpilers, code analysis tools), and then integrate them into Vim and create an optimized workflow that uses them. By making sure you do spend 50% of your time doing actual work, you will ensure that your productivity never gets any lower than when you first start doing this. Knowing that you get to spend 50% of your time improving the experience you have while working, will help you to feel motivated and happy during the 50% work time. The amount of productivity you get during that 50% work time will be constantly increasing. Eventually you will be a one person programming team. Of course there would still be advantages to working with others, but you can get good enough that you alone are getting better results than the average team, and then you can keep improving from there. By making sure you don’t get completely obsessed with improvement and actually spending 50% of your time doing real work, this will give you the real world insights you need to know what kind of customizations or tools will help you get faster and produce higher quality stuff. It keeps you grounded.

    Is this really better than doing the same thing in Emacs? I think so. Like I said,l you could integrate Neovim into emacs. That would be interesting. My fear is that since Emacs is designed from a modeless mindset, you would constantly be fighting against it and tools designed for it to be able to use them in an optimized (modal) workflow. But that is more of a fear than anything I have actually confirmed. You could integrating Neovim into Emacs, and then make all your own plugins that are designed from the ground up with a modal mindset, would result in the best experience in the end. But at that point, what is the advantage of running it inside Emacs? There is are some Node based GUIs out there for Neovim. This may be the way to go if you really want to get Neovim to be a windows manager in a similar sense to how Emacs can be that. I imagine you could use that to run websites directly inside your GUI, and other UI based javascript code.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.