Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can someone very briefly explain the popularity of emacs and vim among programmer types? I'm aware that they're unix based text-editors with some degree of reprogrammability... but what's the big deal?


The gist is that these editors are both customizable to the extent that proficient users don't see the need to go elsewhere. They're both keyboard driven, so one finds their productivity soaring as their dependency on the mouse decreases. They're text oriented, so moving around and manipulating text is much more natural and speedy than other modern editors.

In short, give either a shot. You might find it does everything and more that your current editor does. Neither be 100% comfortable to you over night, but in time you'll wonder why you worked with anything else.


Both? There is only one.


It's a fair question. Emacs is one of few editors left that makes it possible to work on multiple files at once without taking your hands off the keyboard. No fumbling with the mouse. Watch someone who has mastered Emacs edit some code and you'll understand its appeal.


Going a little further, Emacs is itself (at least a lot of it, including js-mode, for instance) written in Emacs Lisp. This makes most of it modifiable by its user. It's not impossibly hard either - I have made a minor mode for Pyccuracy tests in a couple hours. Learned some in the process.

Even the "configuration files" are, really, Lisp code, not bags of values and options.


Just to add to the language-configuration thing on the vim side...

Vim configuration is also not a bag of options and values; by default, it uses vimscript. vimscript is an interesting language (supports a form of OOP) but only really usable in the vim world, so it is up to you if you want to learn it to do things besides assign values to options.

Alternatively, vim allows you to do editor customization in perl, and while I have found very little documentation for it, it also supports mzscheme.

How does this kind of thing help anyone? Why is Notepad just not good enough? You can add entire text-manipulation features to your editor, including Intellisense to your specifications, tools for refactoring, integration with other tools outside the editor, and so forth.

Both editors have large communities and have few real competitors for fast and powerful text editing (I hear TextMate comes close).


I just checked the breakdown with sloccount.

C: 20% ELisp: 78%


The parts that are written in C are mainly the lisp interpreter itself, and some windowing stuff. Unless you are doing something really strange you never need to dive into the C internals.


What's the last 2%?



"magic"... ;-)


I'm too tired to think of just the right witty comment, but no one ever truly masters emacs; there's simply too much to learn. Which is what makes it so fun - it's a continuous learning process, where there's always something new and cool to be dug up.


Hmm, I'm still not quite sure I 'get it.' For instance, your comment, 'no fumbling with the mouse' confuses me. I've always viewed the mouse as something that saves time, a shortcut to where you want to go or what you want to do. Especially on a Mac with non-maximized windows and Exposé mapped to a mouse button, I've never felt like I was 'fumbling.' I guess I'll ask an Emacs user to demonstrate next time I meet one.


Exposé breaks down when you have a hundred buffers open, though. iswitchb cuts through that like a bullet through butter.

The mouse is better for some things (especially relative/spatial stuff), and the keyboard for others, but interfaces that make you switch back and forth are clearly problematic. Rather than popping up dialog boxes and alerts, Emacs displays results (such as compiler output) in another buffer. If it needs immediate input, it uses the minibuffer, a one-line buffer at the bottom of the screen.

In either case, its full text-editing functionality is available. You can run a directory browser/editor, a web browser, shell, interpreter, e-mail client, irc client, etc., and it's just another text window.

FWIW, Marco Baringer's SLIME screencast ( http://common-lisp.net/project/movies/movies/slime.mov ) is a pretty good example of proficient Emacs usage. That convinced me to try Emacs after using vi for several years.


Ok after watching that link and reading these comments i'm starting to understand a little. I installed Aquamacs (other emacs clients were too ugly IMO). I can see that emacs perhaps had a lot of features Visual Studio had BEFORE vs, and that it's a stable, multi-platform, multi-language environment. I can see also that some of the text editing/formatting functions would probably work better than what I currently use Excel for. I can see the attraction of an uncluttered dashboard/interface too. And extensibility. But as a beginner I can't yet relate to this 'context-switching' problem and the appeal of running all sorts of applications inside a text editor.


No problem. I'm not trying to convince you one way or the other (heck, I use vi too), but I figured a video might help.

Also, for you or anyone else reading this thread, http://emacswiki.org/ is the place to go for info.


Thanks for the slime.mov link, I learned a couple of nice things about Emacs UI from that.


There are operations where the mouse is more efficient than the keyboard and vice versa. Anyone who says otherwise is selling something.

That said, I often trade the time + context switch of moving to the mouse for a slightly less-efficient keyboard command. Overall it's probably a toss-up, I just like to stay near the home row.

My friend at work uses the mouse a lot and he's very good at using it to edit text.


Agreed. IDE with extensive keyboard shortcuts + using the mouse occasionally for the odd-length text jump/highlight VS emacs baroque command structure is probably about the same for those who have mastered each. Years of surfing the web have most people very adept and quick with a mouse.


Huh? I can edit multiple files in Windows Notepad by pressing Alt+Tab. There are some nice features in Emacs but any editor allows working on multiple files without a mouse.


That is technically true, but no one would actually be productive in that environment. Switching to the file you want is an O(n) operation with that workflow. That would drive anyone insane. In proper editors you can switch to the file you want by hitting a command and then typing a few chars of the file you want, then return.


Nonsense. I've done it both ways, and doing it the way you describe is actually slower.


It's slower for small N. That's why emacs has Tabbar mode, which I have bound to \C-Tab.

http://www.emacswiki.org/emacs/TabBarMode

Tabbar works great for switching between the 3 haskell files I have open (note: tabbar only switches between files of the same type).

Regular buffer switching (or even better, anything mode http://www.emacswiki.org/emacs/Anything) works great for switching between the roughly 200 java files I have open right now.


You can bring up Emacs' buffer list sorted with the most recently used at the top (bs-show). This is equivalent to alt-tab in the worst case. Because I can search this list (it's a standard Emacs buffer), I can get to anywhere in the end or middle far faster. You cannot see filenames in alt-tab until you select the icon.

Further, Emacs standard switch-to-buffer command selects the last visited file by default so you can flip between files with C-x b RET. Slightly longer than alt-tab, but not much once it becomes muscle memory.


Perhaps that says more about the person than the method.


Don't... even... start. ;)


One nice point about vi(m) especially is the fact that its available almost everywhere as most unixy installations got one.

And a nice point of text-based programs generally is that they are easy to use over ssh allowing you to access your programming environment everywhere.


Here's a dumb question: most *nixes come with vi as the text editor, but the shell uses emacs keybindings. Why is that?

(btw, if you learn emacs well enough, you're commandline-fu goes through the roof)


"the shell" usually means (on modern Linux distros) bash, which is the "GNU Bourne-Again SHell".[0]

Brian Fox[1] developed the readline library to handle bash's interactive input. Between Brian Fox having been an Emacs maintainer, and bash being a GNU project, the keybindings followed suit...

Had bash been "Bill Joy's[2] Awesome SHell," things might have gone differently :-) Well, it would've just been csh[3] (written by Bill Joy.)

[0] I address this introduction to anyone not already "in the know."

[1] http://en.wikipedia.org/wiki/Brian_Fox

[2] http://en.wikipedia.org/wiki/Bill_Joy

[3] http://en.wikipedia.org/wiki/C_shell


Actually the keybindings can be changed to those of vim (by typing "set -o vi" on terminal). It is probably not set as default as it is confusing to new users.


So, Emacs can be any or all of 4 things depending on your point of view.

1) lisp interpreter

2) text editor library written in lisp

3) a very flexible text editor

4) whatever you want to make it

Because it's a general purpose programming language you can write anything you want in Emacs lisp. That's why you find tetris, web browsers, and e-mail clients written for Emacs. There's a great culture of sharing your work too[1], so Emacs can be a powerful toolkit that supersedes traditional shells in some ways.

You have unlimited access to customize your editing experience. Everything the editor does can be changed because you have the same access to the interpreter & libs as the editor itself. Every key can be bound to a function, and the normal alphanum chars and such are bound to insert themselves by default, but you can change that. So if you want { to insert the closing } automatically, you can do that without much trouble. You can write it, evaluate the code, and then use it instantly without restarting your editor.

Personally I just use it for coding, but for me coding includes running zsh and a host of other REPLs. (ruby, python, javascript, ...) Some of the packages I have used approach or exceed IDE levels of integration with the project being worked on[2][3].

You can compile a C program or run grep and then step through errors/warnings or search results visiting each line and doing what you need to do. This is one way that Emacs one-ups the shell which prints static text as output. Emacs wraps that in an interactive interface, which is great in a lot of situations.

[1] http://www.emacswiki.org/

[2] http://rubyforge.org/projects/emacs-rails/

[3] http://github.com/samsonjs/mojo.el

edit: One really cool thing I forgot to mention: js2-mode. Steve Yegge wrote a JavaScript parser in Emacs lisp which means that when editing JavaScript - which I do a lot of these days - the syntax highlighter has an immense amount of information to work with. Global vars are coloured differently from local vars (very important in JS as undeclared vars are implicitly global, ugh). Syntax errors get underlined in red instantly. If you've experienced this in other IDEs you appreciate how awesome this is. You never run your code only to find that you made a stupid syntax error that needs fixing. Someone could use js2-mode to write advanced IDE-like functionality for JS, such as renaming & refactoring.

Anyone could implement something similar for any other language, if they have the time & will.


Their popularity comes from a few places:

1) Both vim and Emacs are really really good at basic text manipulation. This means for navigating files and entering/changing text, they're really quick (and don't require a mouse). Most other editors and IDEs are really bad at this.

2) They're amazingly customizable, which means whatever you want your editor to do, they can do.

3) People love messing around with them. I've been there, and I can tell you it's really fun. Finding all the amazing little things Emacs/vim know how to do, finding that extra few lines of code to make that make them do some neat trick, it's all very fun for people who love tinkering with their tools.

Disclaimer: I am not an active Emacs/vim user. But I have used both for long periods, and I respect the amazing things they can do and teach.


A previous post from HN summarizes some of this:

http://news.ycombinator.com/item?id=403967




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: