What are the pros and cons of Vim and Emacs?

374,028

Solution 1

I use both, although if I had to choose one, I know which one I would pick. Still, I'll try to make an objective comparison on a few issues.

  • Available everywhere? If you're a professional system administrator who works with Unix systems, or a power user on embedded devices (routers, smartphones with Busybox, …), you need to know vi (not Vim), because it's available on all Unix systems and most Unix-like systems, whether desktop, server or embedded. For an ordinary user, this argument is irrelevant: Emacs is easily available for every desktop/server OS, and since it supports remote editing, it's enough to have it on your desktop machine anyway.

  • Bloated? Emacs once stood humorously for “Eight Megabytes And Constantly Swapping”. Right now, on my machine, Google Chrome needs about as much RAM per tab as Emacs does for 100 open files, and I won't even mention Firefox. In the 21st century, Emacs bloat is just a myth.

    Feature bloat isn't a problem either. If you don't use it, you don't have to know it's there. Emacs features keep out of the way when you don't use them and the documentation is very well organized.

  • Startup time: Vi(m) proponents complain about Emacs's startup time. Yes, Emacs is slow to start up, but this is not a big deal: you start Emacs once per session, then connect to the running process with emacsclient. So Emacs's slow startup is mostly a myth.

    There's one exception, which is when you log in to a remote machine and want to edit a file there. Starting a remote Emacs is (usually) slower than starting a remote Vim. In some situations you can keep an Emacs running inside Screen. You can also edit remote files from within Emacs, but it does break the flow if you're in an ssh session in a terminal. (Since XEmacs 21 or GNU Emacs 23, you can open an Emacs window from a running X instance inside a terminal.)

    Turning the tables, I have observed Vim taking noticeably longer to load than Emacs (vim -u /dev/null vs. emacs -q). Admittedly this was on a weird platform (Cygwin).

  • Initial learning curve: This varies from person to person. Michael Mrozek's graph made me chuckle. Seriously, I agree that Vim's learning curve starts steep, steeper than any other editor, although this can be lessened by using gvim.

    Since I've dispelled a couple of Emacs myths, let me dispel a vi myth: a modal editor is not hard or painful to use. It takes a little habit, but after a while it feels very natural. If I was to redesign vi(m), I'd definitely keep the modes.

  • Asymptotic learning curve: Both Vim and Emacs have a lot of features, and you will keep discovering new ones after years of use.

  • Productivity: This is an extremely hard topic. Proponents of vi(m) argue that you can do pretty much everything without leaving the home row, and that makes you more efficient when you need it most. Proponents of Emacs retort that Emacs has a lot of commands that are not frequently used, so don't warrant a key binding, but are damn convenient when you need them (obligatory xkcd reference).
    My personal opinion is that Emacs ultimately wins unless you have a typing disability (and even then you can configure Emacs to require only key sequences and not combinations like Ctrl+letter). Home row keys are nice, but they often aren't that much of a win because you have to switch modes. I don't think there's anything Vim can do significantly more efficiently than Emacs, whereas the converse is true.

  • Customizability: Both editors are programmable, and there is an extensive body of available packages for both. However, Vim is an editor with a macro language; Emacs is an editor written in Lisp with some ad-hoc primitives. Emacs wins spectacularly when you try to do something that the authors just didn't think of. This doesn't happen every day, but it does accumulate over the years.

  • More than an editor: Vim is an editor. Emacs is not just an editor: it's also an IDE, a file manager, a terminal emulator, a web browser, a mail client, a news client, ... Whether that's a good thing or a bad thing is a matter for debate. But you can use Emacs as a mere editor (see “feature bloat” above).

  • As an IDE: Both Vim and Emacs have support for a lot of programming languages and other text formats. Beyond the basics such as syntactic coloring and automatic indentation, both have advanced IDE features such as code and documentation cross-reference lookups, assisted insertions and refactoring, integrated version control, and the ability to initiate a compilation and jump to the first error.

    One domain where Emacs is plain better than Vim is interaction with asynchronous subprocesses. That's when you start a long compilation and want to do something else inside the same editor instance while the compiler is churning. Or when you want to interact with a Read-eval-print loop — Emacs really shines at this, Vim only has clumsy hacks to offer. Nevertheless, a new fork of vim, Neovim has proved to have fixed this and implemented other various bug-fixes not implemented in stock vim.

Solution 2

I'll post what I think are the main benefits of each:


Emacs has considerably more extensions to let you do tasks that are only vaguely text-editor related, like browsing the filesystem or messing with version control, and extensions that are in no way text-editor related, like reading RSS feeds. If you want an environment instead of just a text editor, Emacs is going to be better than Vim. I also think Emacs is much easier to learn, despite what some would have you believe:

Editor learning curve comic

In particular, I think a novice Emacs user will be faster than a novice Vim user


On the other hand, Vim is undeniably faster. It seems like this is a core part of the argument, but in my opinion there's no contest at all; I consider myself a fluent Emacs user, and I'm no match for the couple people I know that have an equal knowledge of Vim. The problem is, the number of people that have sufficient mastery of Vim to be that fast is incredibly small (of the ~30 people I talk to regularly who use Vim, I think only one is exceptionally good at it). There's a large gap between the possible speed gain and the actual speed gain you achieve; Emacs users are going to be almost as fast as 99% of Vim users, and (as I said in the Emacs section) beginning Emacs users will probably be faster than beginning Vim users

Solution 3

There is a vi available on every unix system (or almost), however you can't say this about any other editor. This is the #1 reason, imo, to learn and familiarize yourself with vi (please note 'vi' not 'vim'). I've never seen Emacs be available in a default install.

I'm not saying don't use Emacs or this is the only reason to use Vim, but when you want to be able to use Unix systems that aren't yours... vi is part of the universal language.

Solution 4

I think they're both awesome. I think either one can do just about anything you can imagine, and they're both so customizable, that by the time you finish customizing them, they're both just exactly what you want them to be, nothing more nor less.

Emacs stands out to me in being a bit closer (although still does not meet) to ISO/IEC standards of usability and consistency for user interfaces, and hence doesn't play as many tricks with your “instincts” about that vim does. The lifetime of instincts you've developed working with other programs won't work against you.

Vim is a completely different model, and in many ways, it is superior on its own in so far as relies far less on Cntrl/Alt sequences, and instead just on its modes, allowing you to keep your hards on the home row and typing faster. But vim is virtually unique, and unless you install some very unusual accompanying software (e.g., Vimperator, Jumanji/Zathura, etc.), the instincts you develop working with vim won't cross over to other programs and vice-versa. That said, I've settled on vim myself. You've got to settle on one sooner or later, for better or worse, since it's difficult to master both.

Solution 5

I use both on a regular basis. I view Emacs as a "live in" editor, whereas I use Vim for quick, one-off tasks. Superficially, Emacs is much more bloated than Vim is, and so it really isn't quite so convenient to "Fire up" as Vim, but I also find that the philosophies of user interface from one to the other support this paradigm. Emacs is much more built to keep you inside, making things nice and comfortable so you don't have to leave, whereas vim is much more "Unixy" and sees itself as part of a greater tool-belt.

Many people flee from Emacs due to its heavy reliance on bucky bits, but this is a pretty silly reason to me. The real power that Emacs has over Vim is customizability, and with the power of Viper etc, this really isn't an issue. Certainly Vim-Script provides its own level of customization, and if, say, your favorite programming language wasn't provided with an appropriate syntax highlighter you could certainly cook one up, but Emacs is ultimately a self-hosting lisp-machine, and in the end you can do much, much more fiddling with it. There just aren't such tools as gnus or org-mode in Vim, to name a few. In a nutshell, Emacs isn't just an editor, it's practically a god damned operating system.

For manipulating text, I'd say they're exactly on par.

Share:
374,028

Related videos on Youtube

John Berryman
Author by

John Berryman

Updated on September 17, 2022

Comments

  • John Berryman
    John Berryman over 1 year

    How would you compare these editors? What are the pros and cons of each?

    [note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.

    • Ed Schwehm
      Ed Schwehm over 13 years
      M-! emacs RET It's like search google for "google"
    • Travis Gockel
      Travis Gockel over 13 years
      Duplicate of SO question: stackoverflow.com/questions/1430164/… of ubuntu askubuntu.com/questions/804/… and programmers programmers.stackexchange.com/questions/1271/… Gotta love the proliferation here.
    • tedder42
      tedder42 about 10 years
      I'm surprised nobody has mentioned XKCD 378.
    • Mark K Cowan
      Mark K Cowan almost 10 years
      Notice how these questions never bother asking for a comparison with Ed, the one true WYGIWYG editor!
    • Wildcard
      Wildcard over 8 years
      From this xkcd forum comment: "If you are more sys-adminy, working on various machines, especially ones which may be severely broken, then vi makes sense. If you are a developer, working on one machine, especially if you are dealing with a number of complex languages, then emacs makes more sense."
    • Wildcard
      Wildcard over 8 years
      Of course, I prefer Vim even for complex projects, but then again I am a sysadmin, not a code monkey. :)
    • ctrl-alt-delor
      ctrl-alt-delor almost 8 years
      Real programmers/sysadmins use sed.
    • Yves
      Yves over 7 years
      I use vim, because I want to help help poor children in Uganda!
    • sorbet
      sorbet about 2 years
      This question is not opinion-based. "Which editor is better" is opinion-based. "What are the pros and cons of each editor" is not.
  • xenoterracide
    xenoterracide over 13 years
    umm... I know vim has more than one version control plugin. and one of those plugins supports all of the popular systems.... if emacs has more... how many of them do you need that do the same thing?
  • phunehehe
    phunehehe over 13 years
    I'm quite a vim user, but I often find it difficult to use vi, most likely because of the END key (vim supports it, but vi doesn't, or at least doesn't by default)
  • xenoterracide
    xenoterracide over 13 years
    @phunehehe yeah I'd rather use vim than a barebones vi but I'd rather use any vi than have to figure out wtf I'm doing in nano (which if you're a gentoo user who doesn't realize there's busybox vi) you have to do until you get a vi installed ( they may have fixed this by linking vi to busybox now, I got that done in funtoo, but I couldn't really say)
  • phunehehe
    phunehehe over 13 years
    I'll just do with nano until I install vim itself :D
  • Michael Mrozek
    Michael Mrozek over 13 years
    @xeno I don't know what plugins vim does have, so maybe VCS was a bad example, but I'm highly confident Emacs has far more plugins than vim, because vim doesn't subscribe to the "one program doing everything" philosophy
  • xenoterracide
    xenoterracide over 13 years
    @phunehehe if I try using nano I end up with a whole bunch of ijkloOah's in my file... until I realize that I can't use those for navigation. I don't use the arrow keys to navigate.
  • Gaurav
    Gaurav over 13 years
    This goes double for connecting to slow servers across dodgy connections: the one editor they're guaranteed to have (it is in the Unix spec, I think?) is vi, and vi's command mode makes it much easier to edit files with fewer keystrokes when each keystroke takes several seconds to appear on your screen. Of course, step #1 is usually installing vim :)
  • Joe Holloway
    Joe Holloway over 13 years
    @phunehehe I've been using Vim for 3 years now and don't think I've ever hit the End key. What do you use it for?
  • phunehehe
    phunehehe over 13 years
    @Joe to move to the end of a line in edit mode. I know I could have hit Esc then A but that's 2 key strokes. Is there anyway faster?
  • xenoterracide
    xenoterracide over 13 years
    @phunehehe hitting either of those keys requires me to remove my hands from the home row. I'd prefer to hit 2 keys than doing that.
  • phunehehe
    phunehehe over 13 years
    @xenoterracide but reaching Esc requires quite some movement of the left hand, doesn't it? Hitting End looks more comfortable to me. Anyway I don't feel the need to argue about this :)
  • xenoterracide
    xenoterracide over 13 years
    @phunehehe I don't use esc. I use ctrl+[ it does the same thing ;)
  • Andrew-Dufresne
    Andrew-Dufresne over 13 years
    Would somebody please explain what does emacs graph, given above, means? How to interpret it?
  • Kevin Cantu
    Kevin Cantu over 13 years
    I sometimes wonder whether this says more about Lisp or about Emacs, and whether that is good or bad...
  • ocodo
    ocodo over 13 years
    It's a "down the rabbit-hole" joke... It's because when you learn emacs, eventually you start creating emacs too. (since Emacs is really just a very large collection of editing macros/routines written in it's Lisp interpreter.)
  • LawrenceC
    LawrenceC over 13 years
    +1 for Gaurav's comment. Vi works excellent for emergency editing of config files over a crappy 3G connection on a slow cell phone.
  • mr.b
    mr.b about 13 years
    @ultrasawblade @xenoterracide : I registered specifically to up-vote your comments :) +1 vi(m) via 3g (or even gprs... yay). :wq (Oh it requires me to click "add comment" button...)
  • rozcietrzewiacz
    rozcietrzewiacz almost 13 years
    I cannot agree with the point "More than an editor". Vim has also many plugins, including ones that turn it into a file manager or an IDE (like vim-latex).
  • bollovan
    bollovan over 12 years
    Ctrl+C also works to get out of insert mode.
  • amphetamachine
    amphetamachine over 12 years
    @slomojo Vim also has its own Turing-complete scripting language. IMO, it's a mark of a great editor to be able to program it to suit your needs. This is part of why Eclipse is so powerful.
  • amphetamachine
    amphetamachine over 12 years
    "Emacs would make a great operating system, if only it had a text editor worth a shit." -- I was reminded of this quote.
  • Johan
    Johan over 12 years
    +1 your speed vs experience is good, but maybe 99% is a little extreme. I mean vim is not "that" hard to master, it only takes a couple of years ;)
  • gnometorule
    gnometorule over 12 years
    This made me feel small...
  • musicfreak
    musicfreak about 12 years
    @rozcietrzewiacz: Yeah, but can you browse the web in Vim? Read email? Check your RSS feed? I don't think you can deny that Emacs is just plain more powerful, though the usefulness of that power depends on what you're looking for.
  • Konrad Rudolph
    Konrad Rudolph almost 12 years
    It’s not even proven that CTS is actually related to keyboard use. Though superficially plausible, there are links showing that CTS is actually caused genetically more than anything else. So while it may still help to type less when you already have CTS, I don’t think there is any evidence to say that one editor causes CTS more than another.
  • Michael Mrozek
    Michael Mrozek over 11 years
    I assumed everyone reading this would have seen that graph before, but apparently people are under the impression I made it -- I didn't, it's pretty well-known and shows up all the time in vim vs. emacs threads. I think the original source is blogs.msdn.com/b/steverowe/archive/2004/11/17/…
  • Kris Jenkins
    Kris Jenkins over 11 years
    The main reason I use vim is that it's modal. Higher learning curve, but much easier to use once you're used to it.
  • dotancohen
    dotancohen over 11 years
    @xenoterracide: Use this mapping for getting to the end of the row quickly: inoremap kk <Esc>A. I don't ever remember it conflicting with real text that I had needed to enter.
  • Behrooz
    Behrooz about 11 years
    emacs has a media player plugin, or so i heard.
  • tshepang
    tshepang about 11 years
    @amphetamachine I don't get the quote. Does it mean to demean emacs-the-text-editor?
  • remmy
    remmy almost 11 years
    @musicfreak (vim.sourceforge.net/scripts/script.php?script_id=1053 vim.org/scripts/script.php?script_id=4315), (vim.org/scripts/script.php?script_id=1052, code.google.com/p/postmail-vim-plugin), Possibly something like the script in stackoverflow.com/a/567512/805362. Vim has support for scripting in Python, Ruby, Lua and perl, so you can do pretty much anything you want.
  • Erik B
    Erik B almost 11 years
    I enjoyed reading your answer, but I miss the deciding factor. What made you switch from emacs to vim?
  • ConcernedOfTunbridgeWells
    ConcernedOfTunbridgeWells almost 11 years
    It was just organic - plus vim's keyboard macros work really well.
  • Luc M
    Luc M over 10 years
    I don't understand why people would want to browse with Emacs. I <CTRL><TAB> and get focus to Chromo to browse. I've never tried Emacs but I don;t think that Emacs could beat Chrome :-)
  • Bananguin
    Bananguin over 10 years
    "I don't think there's anything Vim can do significantly more efficiently than Emacs, whereas the converse is true." What would that be? If I have use for it I will give emacs a try!
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 10 years
    @Bananguin Emacs is better at anything that involves interacting with a REPL. For example Proof general is very nice (of course it's a very narrow application domain). Emacs is good at doing stuff that nobody thought of before: Emacs Lisp is a lot nicer than Vim's macro language. Emacs tends to have better support for indenting source code but I don't think it's so much a flaw of Vim as a lack of libraries (the Vim support tend to be limited to syntax highlighting).
  • Swapnil Desai
    Swapnil Desai about 10 years
    set -o vi in bash or zsh is not too hard to run (or put in an rc file) in my opinion.
  • Admin
    Admin about 10 years
    @moon.musick - certainly not, I do it all the time. It's just that gnuplot, Postgresql's psql, MySQL's mysql and a ton of other interfaces all do Emacs mode more or less by default. If only Oracle could get sqlplus to do command line editing... no, no. That would be too much to ask of a Major Corporation. They have Trends To Follow!
  • Amitav Pajni
    Amitav Pajni over 9 years
    I always heard it as Eighty Megabytes And Constantly Swapping.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 9 years
    @MichaelHampton You must be young then. In 1985, it was Eight Megabytes. By now I suppose it should be Eight thousand Megabytes, except that nobody notices Emacs's memory usage since it's less than one browser tab.
  • Amitav Pajni
    Amitav Pajni over 9 years
    @Gilles I wasn't allowed to touch the UNIX machines until 1990-ish...
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 9 years
    @MichaelHampton I was still hearing it as Eight Megabytes when I started using Emacs in the late 1990s. IIRC the least machine where I used Emacs had 16MB, so I wasn't too worried.
  • Dmitry Alexandrov
    Dmitry Alexandrov over 9 years
    @BruceEdiger I highly doubt that developers of mysql(1), psql(1), gnuplot(1), also python(1), perlconsole(1), lftp(1), smbclient(1) and indeed lots of interactive programs were concerned about keybindings for line-editing. All of these software just use GNU Readline, and default mode for GNU Readline is (unsurprisingly) GNU Emacs-like. set editing-mode vi in your ~/.inputrc and voila – all these tools have vi-like keybindings.
  • Cody Poll
    Cody Poll about 9 years
    It does mean to, though I usually hear it more tongue-in-cheek that bitingly.
  • Cody Poll
    Cody Poll about 9 years
    As for the editors themselves, I find vim easier to edit text with, but I have to hand customizability to emacs. Vimscript just can't stand up to a lisp.
  • Christian Abbott
    Christian Abbott about 9 years
    To comment on the first sentence of the post: It might be misinterpreted to imply file-browsing or version control are lacking or under-represented in vim. So, to clarify: in vim, file browsing has built-in support via netrw (incl network file system browsing as the name suggests), and many browsing add-ons such as nerdtree. Version control integration is implemented via add-ons like fugitive.vim, vim-lawrencium, etc. The number of plugins might be greater for emacs, but vim still has excellent coverage in these feature areas.
  • Christian Abbott
    Christian Abbott about 9 years
    One comment about the line "the instincts you develop working with vim won't cross over to other programs": The line "set editing-mode vi" can be added to an ~/.inputrc file (on Linux system which support it). This enables vi-style syntax for entering text in programs using readline for stdin, such as the bash shell itself. There can be (sometimes surprisingly) a fair amount of broader applicability to the editing instincts that one develops using vim.
  • Didier A.
    Didier A. almost 9 years
    Damn, as a younger programmer, the ergonomics argument is very appealing. This might just have settled my choice to go and learn VI and VIm instead of Emacs.
  • kenorb
    kenorb almost 9 years
    Re 'More than an editor'. Vi/Vim can be used as IDE. It has built-in file explorer, just run vi +Ex, or try to edit the dir or archive file (zip/tgz) or while editing, run: :Sex! It has also support for tabs (e.g. :tabnew) and you can split windows as you want. I prefer vim more than NetBeans/Eclipse IDEs which are just rubbish and too slow for bigger projects.
  • Cloud
    Cloud over 8 years
    With respect, what is the benefit of emacs being everything and a bag of chips, if we can just create a second connection to a host for other tasks like FTP, file management, music, etc. A German colleauge (and former mentor of mine) often described such a tool as an "eierlegende Wollmilchsau" - useless by design. en.wiktionary.org/wiki/eierlegende_Wollmilchsau
  • Charles Stewart
    Charles Stewart almost 8 years
    It's worth noting that if you like modal editing, Emacs has good support for it through evil-mode - emacswiki.org/emacs/Evil
  • ctrl-alt-delor
    ctrl-alt-delor almost 8 years
    But emacs has tetris.
  • wordsforthewise
    wordsforthewise over 7 years
    You said 'if I had to choose one, I know which one I would pick'. So which one would you pick?
  • Wildcard
    Wildcard over 7 years
    What does the Visual Studio graph mean? I can't think of a sensible (even joke-sensible) way to interpret it.
  • hegez
    hegez about 7 years
    I have actually used nano over 2G to make an emergency edit to a webpage via my cell phone. So one point more to vim, editing it via nano was defitinely not comfortable. Made an account to say that :P
  • Grischan Glaenzel
    Grischan Glaenzel about 7 years
    The author of this graph thinks people are born with the maximum possible level of Vim skills. And here I'm, using Vim for programming from over 5 years and still crawling along.
  • Kusalananda
    Kusalananda about 6 years
    Since the question asked for both pros and cons, this does not answer the question. As far as I can see, it only mentions how other editors ar better than both Vi and Emacs.
  • peterh
    peterh about 6 years
    Any answers are okay for a question, until they answer the question and they are essentially different as the previous ones. "Looks Ok".
  • Elliptical view
    Elliptical view about 6 years
    The Q clearly asks for the cons. And I mention some pros.
  • Duong LV
    Duong LV over 5 years
    Fortunately, there's many people with that problem, and they have built extensions for lots of programs to make them more vim-like.
  • mowwwalker
    mowwwalker over 5 years
    I think it's pretty important to note that Emacs includes "Evil" mode which enables vim keybindings.
  • giordano
    giordano over 5 years
    Harley Hahn wrote in his Unix book in the vi chapter: If you find vi difficult, have a look in the emacs chapter. In the emacs chapter he wrote: If you find emacs difficult, have a look in the vi chapter. (Not exactly the same words).
  • Vlatko Šurlan
    Vlatko Šurlan about 2 years
    @DidierA. Don't forget to check Spacemacs - Emacs with VIM key bindings. It really is best of both worlds.
  • Didier A.
    Didier A. about 2 years
    I went and learned Vim, and then went back to Spacemacs, and actually went back to its holy mode. Since I program mostly in Lisp now, I didn't find the modal and line based editing of VI that great.