732
votes

Without getting into a religious argument about why one is better than the other, what are the practical differences between Emacs and Vim? I'm looking to learn one or the other, but I realize the learning curve for each is high and I can't decide. I have never used an editor of this type (I've always used IDEs), so anything that helps a newbie is a plus.


Before a flame war starts: I'm not asking which is better, I'm asking the differences between the two. I would like an objective comparison.

30
If you use a Mac (OSX), then you will find that many basic emacs cursor movement commands work pretty much everywhere. (For example they work here where I am typing this comment into the web page.) So for Mac users, there is a system-wide benefit to learning at least the following subset of emacs: ^A ^B ^D ^E ^F ^K ^L ^N ^O ^P ^T ^V ^YMatt
@JamesAnderson: in my experience it's the opposite. Been using vim for 2.5 years, then switched to emacs. The emacs people mostly just don't care... "whatever works for you". Here is what ,salespitch says in #emacs <fsbot> We aren't gonna lie. Emacs sucks. Some of us tolerate it, but we can't tell you if YOU'LL be able to. Try it and make up your own mind.Silex
Emacs is definitely a great operating system, but lacking only a decent editor.technical_difficulty
@JimmyM.G.Lim No, it uses the current pager on the system. If you run PAGER=cat man then man will display text directly to the screen.S.S. Anne
@JimmyM.G.Lim the default PAGER is less, usually, whose keys are vim-inspired. That’s not man. It’s less.D. Ben Knoble

30 Answers

527
votes

(the text below is my opinion, it should not be taken as fact or an insult)

With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note-taking, organization, games, programming, shell access, file access, listening to music, web browsing. It takes weeks and weeks till you will be happy with it and then you will learn new stuff all the time. You will be annoyed when you don't have access to it and constantly change your config. You won't be able to use other peoples emacs versions easily and it won't just be installed. It uses Lisp, which is great. You can make it into anything you want it to be. (anything, at all)

With Vim, it's almost always pre-installed. It's fast. You open up a file do a quick edit and then quit. You can work with the basic setup if you are on someone else's machine. It's not quite so editable, but it's still far better than most text editors. It recognizes that most of the time you are reading/editing not typing and makes that portion faster. You don't suffer from emacs pinkie. It's not so infuriating. It's easier to learn.

Even though I use Emacs all day every day (and love it) unless you intend to spend a lot of time in the program you choose I would pick vim

145
votes

Vim is not a shell. And it does not communicate well with subprocesses. This is nearly by design, whereas in Emacs, these elements are included by design. This means that some stuff, like embedding a debugger or an interpreter (yielding a sort of IDE), is difficult in Vim.

Also, Emacs shortcuts are mainly accessed through modifiers, and obviously the Vim interface is famously modal, giving access to an absurd amount of direct keys for manipulation.

Emacs used to be the only editor of the two that was programmable, and while Vim has a lot of weird levels to its programmability, with the addition of Python and Ruby bindings (and more, I forget), Vim is also programmable in most ways you'd care for.

I use Vim, and I'm fairly happy with it.

116
votes

Vim:

  • better as a simple editor (fewer keys required for simple tasks)
  • more active scripting community - internal language: vimscript
  • one central repository of scripts, plugins, color schemes, ...
  • also extensible in python, ruby
  • can be made portable (emacs has some problems with that)

Emacs:

  • non modal by default (most of today's editors have taken this approach). Though there is evil-mode which emulates vim behavior.
  • more powerful language for extending it (elisp is a full blown language, and in emacs you can practically redefine everything; while in vim you cannot redefine build in functions of the editor. On the downside, vimscript is relatively similar to today's dynamic languages while elisp doesn't resemble pretty much anything)
  • more extendible
  • excellent support for GNU tools (the bunch of them)

Personally, I prefer vim - it is small, does what it's supposed to do, and when I wish a full blown IDE I open VS. Emacs's approach of being an editor which wants to be an IDE (or should I say, an OS), but is not quite, is IMHO, outdated. In the old days having a email client, ftp client, tetris, ... whatnot in one package (emacs) made some sense ... nowadays, it doesn't anymore.

Both are however a topic of religious discussions among the programmer and superuser community users, and in that respect, both are excellent for starting flame wars if put in contact (in the same sentence / question).

55
votes

If you are looking for an objective analysis of both the editors, look at their origins and the philosophy behind their respective designs. Think, which one would suit you better and learn it (and learn it and learn it, because it takes time before you being to discover its true utility as against any IDE). An Introduction to Display Editing with Vi was written by Bill Joy and Mark Horton and he explains why he choose modal design and rationale for various key strokes ( it helps me to remember that CTRL-W +W (will switch to next Window and it will same for CTRL W+ CTRL W, just in case you held the CTRL key for a longer duration.

Here is a link to Emacs timeline and has the reference to Multics Emacs paper. Hereis RMS paper on Emacs, where I see the stress is on a programmable text editor (even way back in 1981 and before).

I have not read the emacs papers, but have read Bill Joy's vi paper a couple of times. Both are old, but still you will get the philosophy and you might choose to use the current tool (vim 7.x or emacs 25?)

Edit: I forgot to mention that it takes patience and imagination to read both these papers as it takes you back in time while reading it. But it is worth.

45
votes
  1. Vim was always faster to start up than Emacs. I'm saying that on any machine, out-of-the-box installs of Vim will start up faster than out-of-the-box installs of Emacs. And I tend to think that after a moderate amount of customisation of either one, Vim will still start up faster than Emacs.

  2. After that, the other practical difference was Emacs' modes. They make your life tremendously easier when editing XML, C/C++/Java/whatever, LaTeX, and most popular languages you can think of. They make you want to keep the editor open for long sessions and work.

All in all, I'll say that Vim pulls you to it for short, fast editing tasks; while Emacs encourages you to dive in for long sessions.

39
votes

VI is always available and will run on the most crippled, single user mode, broken graphics, no keymap, slow link machine - so it's worth knowing how to edit simple files in it just for sysadmin tasks.

Emacs is a complete user interface in an editor. The idea is that you fire up Emacs when you start the machine and never leave it. It's possible to have thousands of sessions present.

Whether learning the capabilities of Emacs are worth it compared to using a GUI editor/IDE and using something like python/awk/etc for extra tasks is up to you.

26
votes

I'm a full-blown Emacs fan-boy, but I knew VI long before I knew Emacs. That said, I make all of my people learn VI because it's always available, everywhere. Can't go wrong with either one of them.

14
votes

Seems an answer has been selected already, but the big difference to me has always been the modal vs. non-modal. Vim is modal, which means that it makes optimizations based on a specific set of usage modes. At least that's how I've always looked at it. This makes using Vim a different experience because instead of having a work area that you type code in, you really are telling an environment to act on the text. This is why people say things like with Vim you really are learning a language. The :wq and :s/foo/bar is all part of a shell like environment that edits and reads text.

Emacs on the other hand is much closer to most editors/word processors/etc. you see today. You have a workspace that has a highly programmable interface. That is why you see things like email, irc, shells, etc. As a programmer it is easy to think in terms of saying "take the line number I'm on and do something with the information". The desire to leave the editor becomes less because instead of having to quit, open some other app/language and do things on some text, you have Emacs where you can do these things within the scope of your editor.

The two ideas are not necessarily contrasting, but it is simply that they reveal two different focuses. Personally I use Emacs, but I've seen folks who know Vim really well and can honestly say it doesn't matter which you choose. I tried Vim first but Emacs ended up sticking for me. It is true that no matter what you choose, you should be at least somewhat proficient in Vim as it really is always available.

14
votes

I started with vi, went to emacs, then to vim. I've been thinking of trying out Emacs to see what's changed in the last five years. (Speaking of IDE's, I had gotten into eclipse for a while, but I prefer my terminal window connecting my mac to my (husband's) linux box).

The cut and paste thing has been bothering me lately. Cut and paste in Vim takes more steps than in Emacs, IIRC. And pasting from say a browser to a terminal window is irritating unless you do something fancy that I don't feel like doing, so I put up with the weird indentation. I think, editing multiple files in emacs was easier. At least jumping from one file to the next if you have them both up on the screen.

I haven't played with the fancy features of either vi or emacs, as I just like to get to the business of coding. All I need is the pretty colors and proper tab to space conversion (especially important with python).

I think it all depends on if you want to use :wq or Ctrl-x Ctrl-s (IIRC) to save a file if you don't care about the fancy stuff.

@mgb was correct. I've been in the bare minimum linux to fix something just a month or two ago in a Debian distro. vi was the only editor available.

13
votes

There is a huge difference on a day-to-day level - Vim (or any vi variant) is inherently modal (you go into command modes where you cannot edit) and Emacs (along with most other editors) are not.

Sure, using menus and such you don't have to actually enter command mode in Vim - at first. But to use even a tiny fraction of the power of Vim you will. That is at the heart of the Vim/Emacs debate.

Personally, I also think Emacs is far more extensible. You can find Elisp packages for many things.

I am curious, though, why you are thinking to learn one of these over a more traditional IDE. What is it you want to learn one of these for?

11
votes

I would like to put here a quote from the book "The Art of UNIX Programming":

Many people who regularly use both vi and Emacs tend to use them for different things, and find it valuable to know both.

In general, vi is best for small jobs – quick replies to mail, simple tweaks to system configuration, and the like. It is especially useful when you’re using a new system (or a remote one over a network) and don’t have your Emacs customization files handy.

Emacs comes into its own for extended editing sessions in which you have to handle complex tasks, modify multiple files, and use results from other programs during the session. For programmers using X on their console (which is typical on modern Unixes), it’s normal to start up Emacs shortly after login time in a large window and leave it running forever, possibly visiting dozens of files and even running programs in multiple Emacs subwindows.

What I really want to highlight here is the: «Many people find it valuable to know both

11
votes

There is a lot of thing that have been said about both editors, but I just have my 5 pence to add. Both editors are wonderful and you cannot go wrong with either of them.

I am a vi/vim user for about 15 years now. I've tried converting to emacs several times but every time was rather discovering that vim actually can do the missing thing out of the box without the need to write a lisp extension or install something.

For me the main difference in the editors that vim makes you use the environment/OS, while emacs tries to encapsulate it or replace it. For instance you can add a date in you text by :r!date in vim, or calendar with :r!cal 1 2014, or even replace the contents of you buffer with the hex version of the contents. Eg. :%!xxd, edit hex and then get back with :%!xxd -r, and many more other uses, like builtin grep, sed, etc.

Another example is use with jq and gron. Eg. paste json blob to the editor and then run for tranformation:

:r!curl -s http://interesting/api/v1/get/stuff
:%!gron | grep 'interesting' | gron -u

OR

:%!jq .path.to.stuff

Each of the piped commands above can be run separately via :%!<command>, where % means all document, but can also be run on selection, selected lines, etc. Here gron output can be used as jq path.

You also get the EX batch editing functionality, eg. Replacing certain words, reformatting the code, converting dos->unix newline characters, run a macro on say 100 files at a time. It is easily done with ex. I am not sure if emacs has something similar.

In other words IMHO vim goes closer to the unix philosophy. It generally simpler and smaller, but if you know your OS and your tools, you wont likely need more than it(VIM) has to offer. I never do.

Besides vi is defacto standard on any unix/linux system, why learn to use 2 tools that do the same thing. Of course some systems offer mg or something similar, but definitely not all of them. Unix + Vi <3.

Well, just my 5 pence.

10
votes

For me pros of emacs are,

  • tramp-mode allows you to edit remote files over ssh. just like local files.
  • tramp-mode + dired = full featured sftp client
  • support for every language you will ever need.
  • built in terminal emulator(term-mode) so i can keep coding without switching between applications.
  • extensibility anything you don't like you can change using lisp.
9
votes

For me, emacs has better development tools(not only tags based tools).

9
votes

Benefits of Emacs

  • Emacs has both non-modal interface (by default) and modal one (e.g. it can emulate vim and vi through Evil, Viper, or Vimpulse).

  • One of the most ported computer programs. It runs in text mode and under graphical user interfaces on a wide variety of operating systems, including most Unix-like systems (Linux, the various BSDs, Solaris, AIX, IRIX, macOSetc.), MS-DOS, Microsoft Windows, AmigaOS, and OpenVMS. Unix systems, both free and proprietary, frequently provide Emacs bundled with the operating system.

  • Emacs server architecture allows multiple clients to attach to the same Emacs instance and share the buffer list, kill ring, undo history and other state.

  • Pervasive online help system with keybindings, functions and commands documented on the fly.

  • Extensible and customizable Lisp programming language variant (Emacs Lisp), with features that include:

  • A powerful and extensible file manager (dired), integrated debugger, and a large set of development and other tools.

  • Having every command be an Emacs Lisp function enables commands to DWIM (Do What I Mean) by programmatically responding to past actions and document state. For example, a switch-or-split-window command could switch to another window if one exists, or create one if needed. This cuts down on the number of keystrokes and commands a user must remember.

  • "An OS inside an OS". Emacs Lisp enables Emacs to be programmed far beyond editing features. Even a base install contains several dozen applications, including two web browsers, news readers, several mail agents, four IRC clients, a version of ELIZA, and a variety of games. All of these applications are available anywhere Emacs runs, with the same user interface and functionality. Starting with version 24, Emacs includes a package manager, making it easy to install additional applications including alternate web browsers, EMMS (Emacs Multimedia System), and more. Also available are numerous packages for programming, including some targeted at specific language/library combinations or coding styles.

Benefits of vi-like editors

  • Edit commands are composable
  • Vi has a modal interface (which Emacs can emulate)
  • Historically, vi loads faster than Emacs.
  • While deeply associated with UNIX tradition, it runs on all systems that can implement the standard C library, including UNIX, Linux, AmigaOS, DOS, Windows, Mac, BeOS, OpenVMS, IRIX, AIX, HP-UX, BSD and POSIX-compliant systems.
  • Extensible and customizable through Vim script or APIs for interpreted languages such as Python, Ruby, Perl, and Lua
  • Ubiquitous. Essentially all Unix and Unix-like systems come with vi (or a variant) built-in. Vi (and ex, but not vim) is specified in the POSIX standard.
  • System rescue environments, embedded systems (notably those with busybox) and other constrained environments often include vi, but not emacs.

Source: https://en.wikipedia.org/wiki/Editor_war

7
votes

The biggest difference for me in choosing to use emacs over vim was the built in gdb support in emacs. Vim doesn't have this included in it's default distribution and the project there for integrating gdb and vim was nearly impossible to get working with MacVim

6
votes

Now you do not even need to think about the difference between these two because of Spacemacs. It is a community-driven Emacs distribution.

As it said,

The best editor is neither Emacs nor vim, It's Emacs and Vim.

Spacemacs combines the best from both Emacs and Vim, which make your life and job much easier.

See screenshot below,


(source: spacemacs.org)

5
votes

Its like apples and oranges. Both have different design and philosphy. Vim is a Text Editor while Emacs is a Lisp Interpreter that does Text Editing.

I use Vim because its fast, sleak, and really good at manipulating texts. It has a composable natural key binding that can make your development tasks really harmonic. Vim is based on the simple *nix philiosphy of doing one thing really well - i.e Text Manipulation.

Extending Vim using bash/zsh and tmux is usually easy and allows you learn a lot of things. IMHO this is a good learning curve. The key thing is to learn how to integrate these things to get a larger working application. With Vim you'll need to learn integration because it doesn't naturally integrate unless you tell it how to. Another worthwhile extension which I use is Tig . Its an ncurses based Git frontend . I just have a binding that opens Tig silently and then I do all the Git stuff there.

Its up to the end user to decide what works best. That Emacs and Vim has stood the test of time is proof of their worthiness. Eventually a good programmer needs nothing more than a pen and a paper to be creative. Good algorithms don't need editors to back them. So try them both and see what makes you more productive. And learn design patterns from both these softwares as there are plenty to learn and discover!

4
votes

Emacs has viper-mode, so in some real sense, it provides a superset of features (excepting those described in What Vim features are missing in Emacs with Viper and Vimpulse?).

vi (and VIM IIRC) is lighter weight (it can edit files in place), but offers fewer features (subprocess communication, extension language).

3
votes

Emacs is really more of a do everything program, and vi(m) is really just an editor. If you are editing text, they are both fine, but I prefer emacs, simply because I have to shift one off the home row to move around, and keep typing the wrong things in command mode. I you don't have that problem, vi(m) may be the editor for you.

3
votes

A jaundiced point of view:

vi (not vim) is a professional necessity. You always have some form of vi easily available, no matter what the environment. You can be in vi when in emacs, you can be in vi to build bash commands in unix-land.

Even Microsquish has to support vi (although they do a good job of hiding it) because of gov't and corporate compliance with published standards.

In my opinion, if you are in a hands-on job in a busy environment--not a hothouse flower confined to one fancy rig in a development environment, or in academia--knowing a lot about a fancy editor is a job handicap. Don't learn all the fancy tricks in vim or emacs, and don't develop a bunch of macros to make the editing environment bend to your will. It's an enormous time sink that gets in your way when you attend to different machines that you probably can't justify in a factory environment.

Read Bill Joy's paper--it is a very competent, perhaps even beautiful, engineering exercise in editing plain text very, very fast. Parito's rule applies here: 80% of the fruit is in 20% of the baskets. Editing plain text very very fast is the crux of editing competence--all else is optional--and sometimes hurtful.

1
votes

If you move around a lot from site to site or your job involves loging on to production systems then vim is the way to go.

All *nix machines will have vi installed by default.

Most sysdamins prefer ksh as the default shell. ksh uses vi (or emacs) command keystrokes to search history and edit the command line.

If you dont know vi well you are severely handicapped when you log into a unix box with a standard configuraton.

For this reason alone I would recommend vim as your normal every day editor. I have seen emacs fans tear there hair out trying to amend config files on a bare bones unix server.

1
votes

In your question, you haven't mentioned that you want it to program in Lisp! But as you have been commenting your answers, I have understood that you actually want a LISP programming interface.

For that precise task, simply forget about Vi. Emacs integration with LISP is wonderful! You should use SLIME. You will then have wonderful integration with the REPL, being able to eval functions, buffers or files directly into a running interpreter in an emacs buffer and much more...

1
votes

vim is a handy editor, you simple type vim filename to open the file, edit, save and close.

emacs is an "operating system" pretend to be an editor, you can eval code to change its behavior, and extend it as you like. A mode to receive/send email on emacs is like an email software on operating system.

When doing simple editing, for example, modify a config file, I use vim.

Otherwise, I never leave emacs.

1
votes

I have worked with spacemacs for about 2 years and neovim for about a year now in a production/research environment. Spacemacs is emacs with couple of nice extra features like layers etc. And neovim is a fork of vim again with some extra features.

I am quite unsatisfied with both of them in terms of experience. And I am still on the look out for a long term solution for my text editing needs.

Here is a simple comparison:

  • Neovim, vim, emacs, spacemacs, etc all of those editors consume less ressources compared to most of the editors out there.

  • Neovim/vim is slightly faster than emacs, noticably faster than spacemacs.

  • In terms of editing experience. I can easily say that emacs packages feel superior. I think that's because they blend in better with the core of emacs.

  • Vimscript is nice and there are certainly great projects in the vim ecosystem as well. The good thing is they are better documented than most emacs projects I have seen so far.

  • Both can be glitchy depending on the package you are using. Spacemacs tend to freeze, and neovim tend to display scary error messages, so pick your poison there.

  • Modal editing in vim, is not an intuitive concept, but once you get used to it, you want it anywere. Both of the editor provide that.

1
votes

I was user of vim first, then I switched to emacs, then to vim, now I'm experimenting with emacs again.

  • Both are great editors.
  • Both are very extensible today
  • Both have great plugins and community

As developers we type a lot, and, at last for me, moving around in buffers and files are the biggest repetitive tasks, so I want a editor where I CAN MOVE FAST!

The motivation for experimenting with emacs again is that I fell it Ctrl leaded keybinds faster than vim, and easier to reason about.

In vim you have modes, you have insertion mode, visual mode, normal mode, what happens when you press something depends on the mode that you are, is a stateful aproach to editing. You move, enter in insert mode, edit, get out of insert mode and move again. I frequently lose my self if I miss a ESC press or something like this.

In emacs there is no mode, basically you press Ctrl with your pink and type the keystroke, like C-x C-f, C-x C-s, C-x C-c. There are keybinds where you need to release ctrl key, I hate this ones and always replace them by ones with control pressed.

I think that emacs approach is faster to think and type, but vim has another strength, to. Its commands are composable, they usually has a format . For example, to delete a line you can use dd, to delete a word dw. Plugins make use of that felling, with vim-surround plugin you can delete quotes with ds" (delete surround "), delete up to next / dt/. Delete up to previous /: dT/ and so on. So as long as you learn the moving things start to get very interesting.

Summing up, today I fell that emacs keybinds are faster for macro editing and vim commands are more powerfull for microediting

I've been using vim for the last five years so I edit thinking mainly about words, lines, surrounding, blocks, etc. Delete this line, remove quotes, replace quotes, delete word in cursor, I'm trying to findout the emacs moves for that

As a final quote I would say that, I care more about fzf than about emacs or vim, I would love to have a editor that is completely fzf based

0
votes

Keystroke execution::: vi editing retains each permutation of typed keys. This creates a path in the decision tree which unambiguously identifies any command , whereas Emacs commands are a combination of typed keys executed immediately, which leaves the user with the choice of whether or not to use a command.

Memory usage and customizability::: vi is a smaller and faster program, with a more limited capacity for customization, whereas, Emacs takes longer to start up and requires more memory. However, it is highly customizable and includes a large number of features, as it is essentially an execution environment for a Lisp program designed for text-editing.

0
votes

I think the main difference is the design target. VIM is for UNIX as a working editor. Emacs is for GNU and lisp hackers, so it has some mixed design element.

I use vim on my workstation, while I love emacs too.

0
votes

I am an Emacs fan but encourage other developers to learn VI because:

  1. you can use VI to edit the emacs makefiles.
  2. VI includes ed commands and every UNIX user should know ed and sed.

I've noticed several comments about VIM starting faster than emacs. If you really care about that, run emacs in server mode and alias 'emacs' to 'emacsclient'. The client is super fast since all it does is tap the server on the shoulder and tell it which file you want to edit. On MacOSX, emacsclient is only 33K while emacs is 287M.

I'm not sure any of this is necessary on modern hardware. On my MacBook Pro (2013 Retina), emacs loads almost instantaneously when I run it from the shell. I detect no pause at all. When I run Emacs.app (the GUI version) it might take all of 3 seconds.

Most complaints I hear about emacs seem to come from people misinformed about emacs. Having used both vi and emacs since 1982, I definitely remember a time when emacs loaded much slower than vi and used most of the physical memory in my early UNIX boxes, but that is no longer the case and has not been for at least 15-20 years.

One complaint I will concede is "emacs pinkie". This never bothered me at all when I was younger. Now that I'm 58, my pinkie does get a bit sore from repeatedly accessing the Control key for emacs chording. This is especially true on the MacBook Pro keyboard where Control is moved one position to the right to make room for the "fn" key. It's not nearly as annoying when Control is the bottom left key.

-12
votes

Firstly Vi (original realization) not used today. That you say is some Vim derivation.

To extend Vim functionality you must recompile Vim, Emacs not.

Emacs has Vim in self (viper-mode).

Emacs usually need manually installation, Vim typically preinstalled on all Unix like OS (but if you have ssh access to host tramp-mode win Vim :).

If you try Vim you hate Emacs, so start from Emacs first.

Also read http://www.dina.dk/~abraham/religion/vi-tutorial.html (link go down so use this)

Anwer search in hxxp://en.wikipedia.org/wiki/Editor_war