tags:

views:

2363

answers:

8

I'm using both Vim en Emacs (Vim for a few years, emacs for a few months). I like both but I tend to see Emacs as a bit cumbersome and unfinished. For example some very basic action such as copying a word has to be added if you want it. But I love the fact that you can easily customize it.

I'm currently reading Coders At Work and I love it. I've spotted that everyone interviewed in this book seems to use mainly Emacs. Why is that so? Could it be because a lot of them are from a functional programming background? Or is it simply for the need of customization they have?

Am I missing the point on why Emacs is so great and used by some many great coders?

+4  A: 

Copying a word?

C-<space> M-f M-w

and

C-y

to paste it. Hit M-y to give you previous copies.

I suppose you would have to write a little function and bind it to a key if you want to copy a word under your cursor with one keystroke, but how you would define a word would depend on the mode you were in; you'd want to not copy a paren in a s-exp like (count xs) if your cursor was over count, and etc for other languages.

Emacs allows for customization beyond what you can get with vi(m). Emacs is essentially programmed in emacs (e-lisp), and you get the extensibility that comes with that, along with the learning curve. Vim simply isn't as extensible, though it's also very powerful.

I'd be willing to bet a lot of the people who use emacs also write in a Lisp or two, and the fact that you can both program it in Lisp (e-lisp) and have easy access (via SLIME/swank/etc) to your REPL and entire environment is probably a huge bonus for them. It is for me.

Isaac Hodes
+1 for embedded repl. as a vim user, that is the one major thing I want but cant get when I "look over the fence"
Matt Briggs
+56  A: 

This may be the first time anyone ever accused Emacs of being unfinished. =) In this post, I'll address Emacs as an editor, rather than as platform.

The fact is that Vi(m) and Emacs are hardly comparable. They are both text editors on the surface, but usage patterns are very different, and those only seriously familiar with one often feel like the other is a cheap knockoff of it. The reason there are holy wars about Emacs vs. Vi is that once someone really groks the way of editing with one, it doesn't cleanly translate to the other -- they espouse different approaches to thinking about text editing.

All that said, most users of Emacs customize it, and most professional coders take the time to customize their environment, so the population sampled in Coders at Work may be biased. Sysadmins and other professionals that work across a variety of systems doing tasks that only partially make use of text editing will tend to use Vi: it is part of the POSIX standard (so it is "everywhere"), and it is extremely fast to startup and shutdown, and offers blindingly fast editing for a pro. I'll give you two examples of how usage patterns differ that I've noticed in my work.

Vi users love how fast it starts up, and don't like Emacs' comparatively slow load time. Emacs users keep an instance of Emacs running and use emacsclient to dispatch editing tasks to the running instance, which is as fast as Vi, since Emacs is already running. A different way of thinking.

A Vi user will ssh into a remote host and run Vi there, happy that every system has Vi. If they try to run Emacs, it won't even be on the remote host a lot of the time, so Vi is the obvious choice. An Emacs users will run his or her Emacs session locally and use a mode like TRAMP to edit remote files locally, so Emacs doesn't have to be on the remote host. Again, it's just a different way of thinking.

I know it was just an example, but when I need to copy a word in Emacs (which isn't all that often), I kill it and yank it back: M-d C-y.

R. P. Dillon
It seems like I've had too much vim before so I didn't really saw Emacs as a different solution to the same problem. I've learned a few things too from your answer, thanks :).
afilatun
How can I upvote this answer again?
Caleb Huitt - cjhuitt
You're right that vi(m) is installed on nearly every system out there. But a lot of people do remote editing of files using a plugin named netrw.vim (http://www.vim.org/scripts/script.php?script_id=1075). It supports a variety of protocols and you can edit using the carefully crafted configuration on your own machine. Good answer though!
BigBlackDog
vim's speedy startup/closedown is only revelant if one actually closes one's editor - and why would anyone do that? Then you'll loose all your temporary buffers, your extra notes, your terminals, your file manager and your irc sessions! :/
monotux
Especially the fact that sysadmins often do *not* want to customize, but use standard vi. Think different UNIXes, reinstalls, rescue operations, bootstraps. A neatly configured and pretty Emacs does not fit will with this picture. Cool answer!
Amigable Clark Kant
The answer might provide a guess why some people use Emacs, but the guess to the implied question why they chose it over vim is inaccurate.Advanced vim users do configure their editor a lot.The fact that system administrators might like Vim doesn't mean that programmers don't.Saying vim users like vim because of "how fast it starts up", shows that you don't know vim, and is comparable to saying a sports car is good because its doors open quickly.
Sam
+4  A: 

Well, this is classic flamebait. But, you're not trolling, so, I'll bite.

I use emacs because I can make it fit me with a very minimal amount of grief.

Plugins are beyond trivial to write; they can be just a few lines of code that get evaluated in.

Keyboard remapping is pleasurably easy most of the time. Putty and emacs seem to have issues with the Alt key for me.

I can keep my emacs running for a week straight, and it doesn't consume much memory; it almost always responds fast; it just works.

As a commentary on the awesomeness of emacs, here is Steve Yegge on the matter. http://steve-yegge.blogspot.com/2008/04/xemacs-is-dead-long-live-xemacs.html. (he runs long, as per usual. But it's good stuff)

Paul Nathan
+3  A: 

Regarding your example of things difficult to do: in Emacs, you can copy a word by simply double clicking on it, then paste it into whatever you want. Similarly, you can paste it using the middle mouse button.

Verified on Unix and Windows.

Trey Jackson
Burn the heretic for using a mouse with Emacs! =)
projecktzero
projecktzero: I want to request extra SO votes so I can add more for your comment!
Bryan Ash
@projecktzero Yah, I agree.
Trey Jackson
+3  A: 

There is a philosophy about tools in unix.

Code on remote server? Openssh, to go there, or SSHFS/NFS to bring it to me.

Need to edit some subset of a directory's files? ls |grep *.py

Need to be N places at once? screen/tmux

Looking for something? ctags

How about quickly change local context? ^Z -> fg

Of course you'll need something to deliver these commands: zsh/bash/ksh

Since everything is a file, and text is the lingua franca of unix,

You'll need something to deal with that. Small, fast and focused.

Vim.

Certainly Emacs is more extensible than Vim. But, when you use Vim, your IDE is unix.

Emacs is certainly a great little IDE, but it's a bit small and restrictive for me.

chiggsy
+1 for calling emacs small
Dave
-1 for party line dogma (Emacs is certainly...)
leed25d
+1  A: 

Well, not all of them use vim. I happen to know that Brendan Eich uses vi(m).

But in general, I wouldn't bother looking for deep meanings here. Each editor has its pros and cons (and I use both, though all of my "heavy" coding is done in vim). I almost think of Emacs and vim as languages; with the command sets being the vocabulary/grammar. Given that started using vim first, I usually have to translate my commands into Emacs (which feels awkward) but both are equally expressive. Use whichever editor is best for the task at hand and get on with the code, which is really where the focus should be anyway.

Blake
A: 

It's also worth adding that VI fans may be more systems people.

I have routers (in the "takes half a rack, and gobs of power" sense) that run VI (and these days, usually VIM), same with things like NetApp storage.

I've seen many people do really quite elegent hacks so they can use their local Xemacs to edit remote files, which always falls down with these sort of embedded hardware.

Fluency with VI buys a lot to the admin, fluency with Emacs, not so much.

LapTop006
+2  A: 

Vi is omnipresent. Emacs is omnipotent.

Rahul