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

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 #1 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 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. 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.


    Roger S Reply:

    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.


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


    aone Reply:



    That’s all.


  3. 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.


  4. “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#).


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


  6. 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


Leave a Reply

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