So long, Vim. I’m returning to Emacs

I’d been using Emacs for quite awhile, and about 8 months ago I decided I would try using Vim. I’d only used vi for system emergency work, but knew a number of people that swore by it for regular work. So I decided I would learn Vim and use it for my regular work. I figure that with things like this, I don’t get a real feel for how well they work unless I use them for all my work. So I haven’t really opened Emacs at all in the past 8 months.

Yesterday I finally decided that Vim was not living up to my expectations and I’m in the process of switching back to Emacs. I thought I ought to write down why I’m doing that, for my own future reference… and since nobody has ever written about Emacs vs. Vim, I might as well post it where everyone can see it.

So here we are.

Original Reasons for Using Vim

It would lead to more comfortable typing. Lots of Vim users mention that you don’t have to hold down keys while hitting other keys as much in Vim as in Emacs, and that the movement keys are all on the home row. That’s true, but I didn’t find it to be that big of an improvement, since Esc is a farther reach than anything in Emacs, and let me tell you, you’re hitting Esc all the time in Vim. I found that removing the armrests from my chair made my hands happier than Vim ever did, and swapping Ctrl and CapsLock in Emacs will probably help there too.

It starts faster. I’m not sure if that really was true even when I switched, but it certainly isn’t true on any of my machines today. Both Vim and Emacs have had major version upgrades (v7 and v22, respectively) since I started using Vim. People seem to say that Emacs 22 feels faster, though I don’t know if that’s true. The startup times of the two, if they’re different, are imperceptible.

Vim would use less RAM. Frankly, these days, both Emacs and Vim are way down on the list of things that use up RAM. Heck, kmail has 141MB resident, and each of its two IMAP processes is using more than 30MB. Emacs in X right after start has 16MB resident, 10MB of which is shared, and 25MB VSS. gvim right after start has 8MB resident, 5MB of which is shared, and a 43MB VSS. Emacs tends to use fewer processes for things that vim. So they’re not all that different, and Emacs could come out smaller in certain situations. But the difference is irrelevant on today’s machines, and modern Gnome and KDE apps are many times larger than both of them.

It will make me more comfortable in rescue environments where I have only traditional vi available. Actually, the vi on AIX is so different from modern Vim that this didn’t really help.

It would make me more productive. There are some editing commands that did, but as you’ll see below, it was more than balanced out by other problems.

Things I Liked about Vim

The commands dt, dT, df, dF. Wonderful little things those. Emacs now has M-z (Zap), which is similar to df but can actually go to other lines (a nice addition). And there are easy ways to bind keys to the others as well, though that doesn’t make it a pervasive convention like it is in Vim.

Antialiased fonts. It’s crazy that Emacs doesn’t have this yet. But not a showstopper; I still like good ole 10×20 just fine.

Regexp search-and-replace. Emacs actually has this now, and maybe it had it back then too. M-C-%. Apparently in Emacs22 the replacement expression can also have lisp code in it, which sounds really slick but I can’t see myself using it regularly.

Annoying Things in Vim

Syntax highlighting. The syntax highlighting for most languages in Vim felt like it was about as smart as it was in Emacs about 10 years ago. Strings like "Hello!\"" (in languages where \” inserts a literal “) often confused it. Sometimes quotes within comments confused it. Sometimes it would be confused permanently. Other times, just until I scrolled around in the file or reloaded it.

Indentation. This is much more annoying than the syntax highlighting, really. In many languages — and especially the two modes I’ve used most recently, XML and Haskell — it really, really stinks. The indentation there isn’t aware of syntax, or not very much. Sometimes it is smart enough to know that if an XML line starts with </ that it moves left and if it starts with an opening tag, that the next line moves right. But it’s not smart enough to do this reliably. Not only that, but indentation is not handled with consistent configuration between languages. And even though Vim ships with a ton of language modes, the central docs only cover indentation for C.

I’ve asked Vim experts about this, and have tried all sorts of various tweaks, have read through Vim indentation mode source files, etc. There is just no way to get it anywhere near the intelligence of Emacs for most languages, short of writing my own mode, it appears. This is even worse because when using the backspace key in insert mode, for awhile it deletes individual spaces, and then all of a sudden deletes a big chunk of whitespace back to the beginning of the line. (And no, the insertion of Tab characters is disabled.) Indentation is my complaint about Vim, and something that shows no progress towards being fixed any time soon.

And forget about anything like Emacs M-x reindent-region. This is a syntax-aware indenter. You can write out an entire source file with no indentation whatsoever, and it will indent the entire thing according to the indentation rules you’ve defined and the syntax of the language you’re using. The best I’ve seen in Vim are commands that add or remove space at the beginning of every line in a region.

In short, Emacs seems to “understand” the file format on a much deeper level than Vim, and can automate things to a much better extent because of it.

Too many things disrupt the paste buffer. I can use Y or y to yank some text in Vim, and it’s really, really easy to overwrite that buffer with other things. Yes, I know that I can yank it into a named buffer, but that’s inconvenient and I don’t usually know in advance that I’ll have that need. In Emacs, only C-k and other “large area” commands disrupt it.

Vim doesn’t like you having lots of files open at once. It’s surprisingly convoluted to do this. If you use the basic documented command to edit another file, :e, it closes the file you’re working on. The normal way to open multiple files at once is to use split windows. Well, I don’t like split windows all that well, and often just want to make a quick change in one file — in full screen — and then go back to another. Even though I use set hidden in my ~/.vimrc, it still is annoying and more convoluted than it should be.

Vim can’t create new top-level X windows. In Emacs, I can press C-x 5 2, and poof, I have a second Emacs window in X, and it’s tied to the same editing session and Emacs process. Not a new process, with a different set of files, its own buffers, etc. The same process, same set of files. Just like a split window, but with a new top-level X window instead. gvim simply has no way to do that. This is also a large annoyance.

gqap stinks. This has burned me more than once. I’ll be editing an XML document, and insert some text in the middle of a paragraph. Now I have a really wide line. So I type gqap to reformat the paragraph. My cursor is near the bottom of the screen, so I don’t really see much past the current line. I then save the document and exit. Later I discover that vim considered the entire rest of the document part of the single paragraph, and removed all the different indentation levels at </para> and the like, so it’s completely messed up. Emacs is smart enough to know what is a paragraph in XML mode, and M-q does the right thing. Oh, and Emacs reindent-region can fix the Vim gqap-induced mess.

110 thoughts on “So long, Vim. I’m returning to Emacs

  1. Tim Harper says:

    I used vim for probably one and a half years. It’s a great editor, and I really like the movement keys and chainable commands. However, after switching to Emacs for three months, I’ve begun to notice every one of those weaknesses of vim a lot more. Especially the one where your main register was so easy to be overwritten, that got me all of the time.

    However, it’s not like it’s a dichotomy. I’ve taken viper mode and have modified it in such a way so that rather than trying to override Emacs, it harmonizes with it. I’ve also implemented visual-select mode, so Emacs commands work with the perfectly, but it also brings a lot of the goodness of the feel of vim.

    Perhaps if (when?) I release it, we can and the holy war once and for all. :-)

    I think I will call it vi-harmony. Or something cheesy, perhaps a useless recursive acronym?

  2. AnilG says:

    Hey! EVERYBODY posts about Vim and Emacs! It’s always on! You’re not the first one.

    Like someone else said, 8 months is too early to give up, but it sounds like you haven’t tried. Your issues don’t add up. You’re still a vim newbie. This article is misleading because it’s uninformed and inaccurate.

    The big thing about vim is the command mode. Obviating the need for control keys for everything just breaks the keyboard out into a whole new world. Operations that used to take seconds now take sub-seconds (as fast as you can type) and a whole lot more operations are available. The only editor that could beat vim would be another editor that uses a command mode, but there aren’t any.

    Syntax highlighting plugins do often skip the laborious picky little exceptions that would slow down the interface on low spec machines. You can write your own.

    Indentation was originally designed for C but there are multiple indentation control mechanisms. Roll your own. It’s not hard.

    For ‘the paste buffer’ read ‘the default paste buffer’. If you want to pick and choose what goes into your paste buffer and what doesn’t you need to start naming your paste buffers. Vim’s doing the best job here.

    Vim loves having lots of files open. There’s buffers and windows and splits and all sorts of ways of controlling your file lists.

    You’re upset about not creating a new window because you haven’t figured out how to work with multiple files yet. I never need or want an additional window in vim.

    No-one uses gqap for formatting XML. It’s just not intended. You can set a command to call an external formatter if you need to. This particular issue really reveals how little you’ve got across what vim does. You are complaining that gqap doesn’t format XML? No one told you it would!

  3. rick says:

    Agree with many of your comments. I have been using Vim (and continue to us) for over a year. The syntax and indenting needs work. It’s adequate not good. I basically turned of indenting for HTML.

    And for those who say roll your own :( Who wants to deciper cryptic regular expressions where almost everything has to be escaped twice? And if it was that easy wouldn’t major filetypes like HTML, XML and Javascript be rock-solid by now?

    Still, I love Vim. I find editing on Vim is much faster than having to use the mouse or doing finger gymnastics that require 3 or 4 keys. I can easily switch between Apple and PC keyboards.

  4. AnilG says:

    There is a learning curve for the syntax highlighting.
    I’ve made a couple of simple ones for myself but haven’t tried harder.
    I haven’t noticed any problems with the HTML highlighting and I do use it a lot.
    With some other types they are sometimes documented as not covering specific complex parsing situations but that hasn’t troubled me.

    The indenting control is simpler, and can be done by setting some different options.
    Again, I’ve had no problems at all with indent control. I’m surprised you turned it off.
    What’s the specific problem?

  5. Andy says:

    I digg Vim and Emacs. Both are great editors. Both do things differently. Emacs is a badass because you could just open a shell right there and reboot your unix webserver, then bounce back to your file you’re editing. Vim/Vi is good for editing files, system rescue/configuration. I sometimes even use Nano if I don’t feel like hammering the ctrl key or using command mode in Vim. Pretty much depends on what mood I’m in/what I’m doing.

  6. Nicolas says:

    I use :
    alias em=’emacs -nw’
    that will run emacs in current shell windo with as few letters as ‘vi’.

    Also you can consider the viper mode.
    Emacs does vi ;)

  7. Ben says:

    I’ve been using vim for about a year now, since I finally found myself on a workstation where I really *had* to edit files over a console. And I found it pretty nice, but I have thought about switching to emacs, but never really took the dive.

    It’s good to see that you’ve run into pretty much the same irritations that I did, and that emacs really does handle those better. I’ve really wanted vim to work for me, but there’s too much stuff “out of the box” that just doesn’t work. I think a lot of vim users have adapted themselves to vim rather than the other way around.

    I might miss a few commands like :norm, but we’ll see.

  8. Marc Weber says:

    Try el-get and install vimpulse using it. Then you have vim like editing features (even text objects are supported) in Emacs.

  9. Alex says:

    I was an Emacs-only user for about something less than 10 years. That was before my left little finger got injured (due to heavy use of Emacs in my daily professional programming life). I had to switch to vim. My finger was saved. I still do use Emacs just for debugging.

    Ask any heavy Emacs users about their left little finger experience.

  10. Omari says:

    When I first started using Linux I learned Vim. I had wanted to learn Emacs but something just wasn’t clicking about it–which was odd considering that Emacs is usually considered to be less intuitive.

    But occasionally I look at Emacs again and lately have tried using it to edit Haskell. Using Emacs really shows some of the weaknesses of Vim. The power of haskell-mode to automatically indent the code is amazing. In Vim I spend a lot of time hitting the tab key or << to move things around. Overall the Emacs user interface is more polished, I think–it has great tab completion, for example.

    On the other hand when I'm in Emacs I feel like I'm using Microsoft Word because it just takes so long to navigate the file. I'm using to navigating in Vim command mode, where everything is a few keystrokes away. With Emacs it seems to me I have to hit a lot more buttons. In Vim for instance I often use f or F to go to a certain character on this line. ";" repeats it. Maybe Emacs has an equivalent?

    My current impression is that one can be equally productive in either editor, just productive in different ways. I've liked looking at Emacs to see how it does things differently, and to see some things done so well, but I don't think it will actually make me more productive–especially not so much more productive that it will offset the time spent reading Emacs docs. I'd imagine the same is true for someone going from Emacs to Vim. It takes so long to get really proficient in either editor that, by the time you do that, it's just too much trouble to switch.

    I'm glad we have both these editors so each person can choose what is best for him or her.

    1. Charles says:

      Search for Evil mode on emacs. The best of vim with the power of emacs.

  11. Omari says:

    oops, at the top of my previous comment that should be “Vim is considered to be less intuitive,” with its bizarre modal thing. I think I found Vim’s documentation to be easier to understand.

  12. Mark Wotton says:

    I use Emacs on my home machines, but tend to use vim on remote boxes. I’ve tried to love Tramp, but when connections time out it seems to hang Emacs completely. Life’s too short.

    Emacs is definitely more mainstream within the Haskell world, though :)

  13. Justin Gordon says:

    Any strong feelings on vim-mode versus viper-mode for emacs?

    Also, the Kinesis Advantage keyboard solves the pinky issues, but after about 12 years of using it, I’ve started to get thumb issues, as the left thumb is what I hit the ctrl and alt keys with. Has this happened to anybody else?

    Thus, I’m toying with going to vim like bindings to ease the work on my ctrl-key thumb….

  14. BC Armstrong says:

    “since Esc is a farther reach than anything in Emacs, and let me tell you, you’re hitting Esc all the time in Vim.”

    This is absurd. What made the author think he was required to use Esc at all? Just remap practically any keys (within Vim) you like to Esc and problem solved. I use jj. Switching between normal and insert mode is so fast the editor essentially feels modeless.

    I have no opinion on which editor is better overall (and I’m not a coder so my opinion is worthless here anyway) but people who bash Vim because of the alleged need to use the Esc key simply don’t realize how easy it is to customize Vim to your liking.

    1. John Goerzen says:

      Perhaps, but it’s broken by default, and not mentioned in the introductory tutorials I had read at the time.

      1. SciK says:

        You can remap Caps Lock to Escape at X level, just like you do with Emacs and Ctrl.

        1. aone says:

          Guys…

          ^[

          That’s all.

  15. Ben says:

    gqap is the wrong tool for indenting XML, by the way, it’s intended for prose.

    Actually, it’s the right command, but the wrong text object. You probably DO want either gq or =, however you want to operate on the current XML tag. You’d do this with gqat or =at.

  16. nik3daz says:

    Ctrl-c (and others) will do the same as Esc.

    :e something and then Ctrl-o to go to last edit location until back in previous file

  17. I think that both emacs and vim are damn good and powerfull editors, and both are good to the extent ones knows how to use their features. Aside from that, it is natural that some will feel more confortable with one and less with the other. We are different. :)

  18. pukster says:

    I think your arguments are not that great. For example, you think that the only way to exit insert mode is to hit . You can map the key to do that for you.

    A more valid critique would be “why not have ‘jj’ carry out this role by default since is much more comfortable than .

    There are other even bigger problems. One that comes to mind right now is with word wrap. When you wrap words, the go all the way off the right hand margin and show up on the left hand margin. This is great for plain text documents, but if I have a nested structure (think if-else) which is tabbed, I want the wrapped text to be correctly indented. This is especially a nuisance for LaTex. There is, AFAIK, no possible way to do this with vim.

    It’s best to think of Vim as the world’s coolest Regular Expression. No other Regular Expression will ever come close to it. However, it is not a Context Sensitive language. Therefore, there are some things it can not do.

  19. Gene Selkov says:

    I have been using both vi and emacs for more than 20 years, so the difficulty of learning, the choice of keys and most other issues discussed here are no longer important. Until recently, I had been doing most of my work in emacs, using vi as a sidekick, often doing bizarre things like editing my .emacs. Don’t laugh; it is simply easier to type ‘vi ~/.emacs’ than ‘c-x c-f ~/.emacs’. Sometimes my choice of the editor is totally random. They are basically equivalent.

    The problem is, the emacs-world and the vi-world have substantial islands of non-overlapping functionality. It just happens that nobody in the emacs universe cares about javascript. The only sane javascript mode, js2-mode, does a decent job of highlighting the local syntax, but indentation is hideously inconvenient and ecb has no support for javascript at all. Which means I can’t work on large projects. I still do all my c work and perl work in ecb, but because I make a living coding in javascript, I had to abandon emacs and go into a year-long macvim session.

    Fortunately, TagList does a pretty good job marking up javascript. It, too, does not properly understand the language, but at least it does not break and creates reasonably good overviews for my files and (some) functions therein. Indentation is perfect.

    Emacs has become a frontend to subversion. And this reversal of preferences has occurred simply due to an accident. One of the most popular programming languages simply failed to jump the adoption threshold in emacs-world.

  20. Dennis says:

    Regarding hitting escape all the time, imap jk and you can just hit jk in insert mode instead.

    1. Dennis says:

      Blog ate my brackets, that’s imap jk (open angle bracket)Esc(close angle bracket).

  21. Duckie says:

    Hello

    I think several of your arguments are not really relevant:
    – About the RAM : since in fact, it does not have any impact on a desktop personal computer, it does when you share a network development machine with several developers. We got this problem in my team about emacs.
    – About the fonts : I dont know how you use emacs but when I use it, wether from Windows in putty or on linux in a terminal, I do have anti-aliased fonts, because it depends on the terminal, not the editor.
    – Top level X Windows : Same thing. Gvim is awful, small wonder it doesnt fit your needs. To enjoy a real vim experience, Xterm or Gnome terminal will do nice.

    1. Roger S says:

      Back in 2007 (when this blog post was originally written – that’s right, *6* YEARS AGO) the Emacs GUI (he’s not talking about the terminal) did not have support for anti-aliasing fonts. Now it does.

  22. Luca Bruno says:

    Are you still using emacs? I’d like to point you to a new incoming: http://vanubi.github.io/vanubi/

  23. Tucker says:

    Configuration is your friend.

    When I first started using vim, it felt claustrophobic and slow and difficult to use. After a while I realized that this was because I was using the arrow keys too much, and I realized that I was doing that because I would use them to move around in insert mode, because esc was way too far away. To fix this, I disabled the arrow keys, and I mapped esc to jk. From that moment on, everything felt immensely easier and faster and more powerful. Nowadays I can’t imagine using any other editor. Yeah, some things in vim are pretty broken by default, but those are all things that can be fixed with some minor configuration, or a plugin.

    For example, when I first started with vim, I opened a new tab for each of my documents, as I would in graphical editors. This got annoying really quickly, because you can only have so many tabs open at a time. It’s the same issue with splitting the window. So I did some research, and I found out that I was using tabs and splits wrong. I figured out what buffers were, and how to switch between them in the same window, and I set hidden so I could hide documents with unsaved changes. After a while, this also got annoying, because vim’s buffer switching is kind of atrocious. So I did some more research, and I found probably the most useful plugin I’ve ever seen: ctrlp. This plugin gives you a scrollable list and fuzzy search so you can jump to just about anywhere. You can use it to open files, hidden buffers, recently closed buffers, you can jump to tags, whatever you want. I have ctrlp open in file mode when I press ctrl-o, and in buffer mode when I press ctrl-p. I just hit the shortcut, type bits of the filename that I want (and maybe arrow up a bit), and when it’s selected I hit enter. And it selects the last opened file by default, so if you go somewhere to make a quick change, when you want to go back you don’t have to type anything, it’s already selected.

    I had a few issues with indentation, but I’ve fixed most of them through various configurations and plugins. I’m trying to fix Haskell indentation at the moment (that’s actually what I was googling when I found this article) and I’m sure there’s a good plugin somewhere for it. I think they fixed syntax highlighting for the most part by now, I’ve only seen it get confused a couple of times, and the files that happened with were written in some more obscure languages that I would expect aren’t supported quite as well as the common ones.

    “And forget about anything like Emacs M-x reindent-region. This is a syntax-aware indenter. You can write out an entire source file with no indentation whatsoever, and it will indent the entire thing according to the indentation rules you’ve defined and the syntax of the language you’re using.”
    In vim, this is the ‘=’ key. So ‘gg=G’ to properly indent the entire file, ‘=ap’ for the current paragraph, ‘==’ for the current line, etc.

    “Yes, I know that I can yank it into a named buffer, but that’s inconvenient and I don’t usually know in advance that I’ll have that need.”
    You can put from a buffer number. Vim saves the last ten yanks, so if you need an older one you can just check which number it’s in and use that as the buffer name.

    “Vim can’t create new top-level X windows.”
    … I can’t imagine why anyone would ever want this. If I wanted multiple top-level windows I would just use MS Notepad. Window splits work fine. I guess if you wanted to keep your splits the way they are, and open a new window with different splits for other files, that would make sense … but then, just use tabs. That’s what they’re for.

    “gqap stinks.”
    Vim has a very particular definition of what a paragraph is. If you don’t want to wrap a vim paragraph, use a different gq command.

  24. Steve SP says:

    “If you use the basic documented command to edit another file, :e, it closes the file you’re working on. The normal way to open multiple files at once is to use split windows.”

    Not exactly. Vim still leaves the file you were working on open in another buffer. You can see what files are open in all buffers with :buffers and you can jump between buffers with various commands (e.g., :bp, :bn, :b#).

  25. John says:

    Come on people, install Sublime Text already and stop playing with stone-age tools just because it makes you look hip and cool.

  26. The biggest thing I miss in GNU Emacs is multithreading.
    So I can’t blindly use the server-mode for everything. I require separate instances for things that might lock me in.

  27. Improved Appearance: Dental implants are fused with the bone to make them appear and feel
    just like original teeth. The various reasons for loss of teeth
    include accidents, tooth decay, gum diseases,
    or birth defects. Oral health has become a subject of awareness in Toronto these
    days.

Leave a Reply

Your email address will not be published. Required fields are marked *

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