tags:

views:

2599

answers:

16

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 don't see a difference between them so I can't decide. I have never used an editor of this type (I've always been a bigger fan of IDEs), so anything that helps a newbie is a plus. I'm using Windows, if it matters.


Before a flame war starts: I'm not asking which is better, I'm asking the differences between the two. Please keep the fanboy comments to yourselves. I would like an objective comparison. Thank you.

+1  A: 

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

Grant Limberg
I used Vim for editing, and Xcode for debugging, it's less than ideal but doable..
StackedCrooked
+4  A: 

There is a huge difference on a day-to-day level - vim (or any vi variant) is inherantly 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?

Kendall Helmstetter Gelner
I just want to learn it to see if it stands up to its hype, to be honest. I've seen how flexible both of them are, and I've seen experts do some pretty crazy stuff in them, and I want to see if it's worth the learning curve. Plus, my IDE doesn't support Lisp. :)
musicfreak
Hmm. The problem is that there is so much of Emacs... but the thing I still leave an IDE for to use emacs is complex series of repetitive tasks, which I automate using macro recording. For example you can take a current word or expression, copy that into a "buffer" (think cut / paste only you can have more than one), then go into another file, type some text partly using the copied value and then another previously copied value as well, advance the cursor, save the position and return to the first buffer again... then repeat the process for the next line of the original file.
Kendall Helmstetter Gelner
And you can save that macro for later if you want, or just let it die with the editing session if you have no need for it later.
Kendall Helmstetter Gelner
KHG: Vim excels at using macros for exactly those sorts of repetitive text-editing tasks (arguably, it's even better than Emacs, as you generally will need far fewer keystrokes to set up the macro)
Steve K
I have used Macros heavily in both vi and Emacs. What you are missing is the fact that Emacs has a far wider selection of methods to access while using macros, and the fact that you can use cut buffers everywhere - even in the middle of search terms for example. Please tell me how you would write a macro that would select one word of an expression based on a regex, take the found term, search another document on that term and then do replacements around it?
Kendall Helmstetter Gelner
@kendall-helmstetter-gelner - that is possible with vimscript, or the languages vim has bindings for (like ruby/vim/tcl/perl). You have access to all of vim's functions and editor buffers from the scripting languages.
segy
+17  A: 

Vim is not a shell. And it does not communicate well with subprocesses. This is nearly by design, where as in Emacs, these elements are included by design. This means that some stuff, like embedding a debugger or a intepreter (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 proagrammable, and while Vim has alot of weird levels to it's 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.

Svend
+9  A: 

Vim:
- better as an editor
- 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 (most of today's editors have taken this approach)
- 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 putted in contact (in the same sentence / question).

Also, the differences between both have already been covered in several questions in here, so for the finer details search a little on the topic.

ldigas
"better as an editor" is pretty vague. I'd be interested in seeing reasons why.
Allen
@Allen - What is vague in it ? I rarely meet users of both vim and emacs, who have a problem with that statement. Even hardcore emacs users usually accept it as a fact. Have you used both editors ? I believe it is relatively obvious that vim has an advantage in the aspect of text editing features.
ldigas
I am incredulous that anyone would accept that as a fact. As a long time user of both emacs and plain VI, I have used vim a few times - but "better as an editor" has to go to emacs in my mind if for no other reason than a far wider selection of major and minor modes to help you as you type.
Kendall Helmstetter Gelner
Vim is better as an editor because manipulating text requires less movement of your hands and fingers than emacs, at least that is my experience.
StackedCrooked
@Kendall - Minor/major modes are not text editing features per se. Otherwise, we could take completion also as a text editing feature. What I ment under this while writing it, was text manipulation features.
ldigas
But that aside, effectively vim is better suited for editing: line numbers, visual mode, manipulation http://wint1.kaist.ac.kr/files/attach/images/59/450/vi-vim-cheat-sheet.gif . FCOL, I had trouble getting emacs just to scroll one line at a time.
ldigas
+1  A: 

Emacs has viper-mode, so in some real sense, it provides a superset of features (excepting those described in this question).

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

Trey Jackson
+1  A: 

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.
Hamza Yerlikaya
FWIW: vim pretty much has the first 3 (though with different names. "tramp-mode" is "netrw" in vim). #4 is generally considered a bug, not a feature by vim users. #5 is true in vim if you replace "elisp" (the worst lisp dialect ever, my Emacs-loving friends tell me) with python/mzscheme/perl/ruby/tcl/vimscript.
Laurence Gonsalves
+5  A: 
  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.

Yawar
+8  A: 

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 1000s of sessions present.

Wether 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 upto you.

Martin Beckett
I know VI for just those reasons - but these days I would say it's pretty unlikely you'd encounter a UNIX system without at least a basic EMACS installation, and it can make a poor shell environment more tolerable.
Kendall Helmstetter Gelner
True but it might not work in rescue mode with no keymap or term set - I have fixed systems where using the 'hijk' was the only option.
Martin Beckett
Also, even busybox contains a mini vi implementation, so you may even find it in embedded systems.
smcameron
Or, jam busybox into an initrd and debug a broken storage driver for the boot device, so early in the init process that all you have is the initial ram disk, and yet you *still* have an editor -- vi.
smcameron
mgb, surely you mean "hjkl"
glenn jackman
After a while with vi, your fingers know the movements - but you can't remember what the actual keys are!
Martin Beckett
+2  A: 

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

barism
+1  A: 

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.

Joe Casadonte
+2  A: 

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.

Elizabeth Buckwalter
This still isn't one and done, but it is much easier than adjusting all the settings that mess up terminal pastes. Use `:set paste`, then paste your text and when you're done `:set nopaste` will go back to normal mode. There is also the `:set pastetoggle=<F2>` command that will toggle this using your chosen key combo.
hbar
+4  A: 

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.

Senthil Kumaran
A: 

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

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

gavenkoa
You do not need to recompile vim to extend it. You don't even need to quit vim.
too much php
Have vimscript/Python/Ruby/etc access to all Vim internal structures?If editor codebase help make extention or complexity of extention on one level of complexity of EDITOR?
gavenkoa
Much of Vim scripts like intelectual MACROS. To extend Vim you need plugins ((
gavenkoa
viper-mode only emulates vi, not Vim. It's a big difference for someone who get used to work with Vim
MBO
+30  A: 

(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 be from there. You write your own extensions, use it for note taking, organisation, 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 recognises 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

James Brooks
W.r.t not having it available: I suggest putting your .emacs and .emacs.d in a source control repo, and so getting your perfect Emacs setup is simply a matter of a checkout.
Duncan Bayne
+1  A: 

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.

elarson
A: 

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.

James Anderson