Why and how I switched from Vim to Emacs
NOTE: I have no intentions of starting another editor war. Opinions expressed here are my own.
Over five years ago, I realized that using editors like nano and Gedit wouldn’t suffice. The need to learn a real editor arose as I wrote more and more code. By nature, I’m a minimalist. I hate clicky flashy bloated things like GNOME, KDE, Compiz, Beryl etc. Emacs is large, graphical and consumes eons of memory compared to Vim. I had also just learnt touch typing and was eager to put that knowledge to use. Emacs didn’t appeal to me at all with its complex META and CONTROL keybindings and its complicated GUI. Vim, on the other hand was small, simple, ran off my terminal and had very simple keybindings. I took to Vim immediately and progressed to become very good at it. Vim uses muscle memory heavily- once you’re that good at Vim, you don’t have to conciosly edit anything; fingers move on their own and it feels like Vim is reading your thoughts. It’s the principle concept as touch typing. Which is what makes it so hard to switch. It struck me that there was something about Emacs worth learning over a year ago, but I was never really able to use it.
I wanted to do so much more with Vim when I realized that it was crippled. Everyone seemed to be talking about those features being present in Emacs. Consider a simple task- editing a file over the network. In the Vim world, I’d ssh into the remote machine and copy my ~/.vimrc and ~/.vim over, praying that the same version of Vim is present on the remote machine. Then using screen (see GNU screen) sessions, I could resume work. In the development front, I learnt that Vim had lots of features hardcoded for C/ C++, but not other languages. In Python, I had to use indentation-based folding to select codeblocks. I wished that Vim behaved more intelligently and do context-specific tasks. A :make in C or C++ is not the same as the :make in Python or :make in LaTeX. Vim didn’t understand this.
Writing and debugging were also separated- I couldn’t really debug anything from within Vim. This wasn’t critical until I ventured out to learn a Lisp. In Common Lisp, writing code and debugging it are so closely related that it was impossible to keep switching between applications to do it. Everyone recommended SLIME (Superior Lisp Interaction Mode for Emacs). I tried to switch retaining the keybindings using tricks like Viper mode for Emacs, but to be honest, nothing really worked out. Purists encouraged me to use Emacs as-it-is without these cheap tricks. I kept looking for Vim equivalents for several tasks and kept failing.
Few people understand the real difference between the two editors. They go on and on comparing the number of keystrokes required to do equivalent operations. I did the same for some time until it struck me- Vim is a dumb text editor, Emacs feels like some sort of intelligent organism. No real equivalents like the Vim “vawy…p” existed in Emacs- why? because Emacs is more intelligent in that. Vim doesn’t understand what a “function” or “codeblock” is. It simply understands characters and lines. Vim is a superb dumb text editor, but nothing more. Emacs, on the other hand, seems to understand what you write and assists you more intelligently. It doesn’t require the basic text editing functions that Vim has at all. I’ll give you an example. Recently, M-z or zap-to-char function was introduced into Emacs. Initially, I was very excited about it, because majority of my commands in Vim were dt, df. Now, I rarely use the command. There’s little doubt about it- In my Vim time, I could have beaten any Emacs expert at basic text editing. Vim does it faster. Emacs doesn’t even have many of those keybindings.
Then why? Because I came to realize that programmers do a lot more than just basic text editing. Vim and Emacs assist the programmer in different ways. Vim helps the programmer save time on basic text editing functions while deserting him when he wants to do his compiling or debugging or even interact with an external application. Emacs, on the other hand, seems to understand the code and helps the programmer operate on code entities, rather than characters and lines. SLIME is easily the best development environment I have seen. Emacs interactions with external applications nicely. Even documentation is readily available within Emacs.
What gives Emacs its so-called intelligence? A major part is contributed by it minor modes. When I open a certain file, some specific minor modes get activated and keybindings invoke context-specific functions. I loved the context-specific help. In latex-mode, I could preview the document I was writing with the same keybinding that I used to compile lines in elisp-mode. The same keybindings mean different (but comprehensible and expected) things in different minor modes.
As I started using it more and more, I understood the true nature of Emacs. Emacs is actually just an elisp environment bundled with several snippets of code written in elisp. Every keybinding invokes an elisp function (ok, some are so basic that the functions are compiled in C. But there are few immutable functions like this). This allows it to be infinitely extensible. Today, there are several brilliant elisp programs like emacs-w3m, emms, eterm, rcirc etc. which allow users to do email, chat, browse the internet and do a lot more, right from within emacs. SLIME is also just an elisp application. In Vim, everything’s written in C and keybindings are hardcoded, which is what makes it rigid.
At the end of the day, I have realized that average programmers can be equally productive on both Emacs and Vim. The question is simple- do you want your editor to assist you with basic text editing or higher tasks? And as programmers become better and better at what they do, I personally feel that they require assistance with higher tasks and not basic text editing.
May 18th, 2009 at 7:03 pm
Emacs doesn’t hold a candle to Vim when it comes to ergonomics and the amount of gymnastics you have to do to get anything done. Unfortunately, it’s probably the _only_ thing that emacs doesn’t do better.
How do you cope with the arcane finger placements?
May 18th, 2009 at 7:07 pm
:D Welcome to the emacs world
If you haven’t done so, try emacs23. It is still not a released software, but I have been using emacs-cvs on Archlinux for over a year now. It works just great.
Also, you made a great point in your final line. Emacs is not a basic text editor with highlighting. This is most certainly what vi is. But vi is a UNIX tool. You can pipe data into vi and reuse your terminal tools. This is lacking in emacs because emacs is an environment by itself.
The only major emacs-grievances are
1) Its bloat
2) Its choice of elisp as the extension language.
1) It is _not_ bloated. It does not suffer from featuritis unlike jedit and some other browsers. It is heavier. But on most modern systems, is a second or two behind gvim. The time you take to type the shebang
2) Elisp is beautiful and powerful. The rest of GNU uses guile. But emacs is too entwined with elisp from days of yore. Also, pymacs is an alternative. But not many python modes are looked at in good light by the emacs world. We need a language designed for AI to extend an editor that is really intelligent
May 18th, 2009 at 7:08 pm
@sykora: Well, If that is the only dislike, yi might be the answer.
May 18th, 2009 at 7:10 pm
Skyora: It becomes much easier when you swap Ctrl & Caps.
May 18th, 2009 at 8:51 pm
@Sykora: Yes, ergonomics is certainly a trade-off. I hope you understand why Emacs can’t conceptually have the same ergonomics:
Joy and Mooleaner chose to hardcode the keys they thought would be most intuitive. The trade-off is extensibility. The plugin interface for Vim is plain sad.
Stallman chose to build an elisp environment and write everything on top of it. Together, the community wrote lots of elisp function and macros for this environment and Emacs was born. Ofcourse, every exposed function (whether or not bound to any keybinding) can be accessed via the execute-extended-command function, which is bound to M-x by default. There turned out to be such a large plethora of functions that it couldn’t possibly be mapped to the 26 + extra keys already. In other words, what I’m trying to say is that Vim = Super tight integration => Lack of extensibility and Emacs = (Anyone can chose their own set of bindings) => Superb extensibility. Imho, the Emacs pinky is exaggerated.
@Baishampayan: He uses Colemak. Caps lock is backspace already :P
@ScriptDevil: Within the first two months, people’ll figure out what to put in their ~/.emacs to strip it of the useless features and hook the useful features and get it to start up faster.
May 18th, 2009 at 10:09 pm
@ScriptDevil: I’m looking at yi, it seems nice. Needs a deeper look.
@Baishampayan: Like he said, CapsLock is backspace for me, and I’m good with that.
@artagnon: The plugin interface for vim _is_ sad, no doubt about it. There are a lot of other things wrong with it, its sorry excuse for a scripting language, and everything generally feels klunky. You’ll get no arguments from me there.
I’m not talking about the key choices for each function, they can always be remapped. I’m talking about the concept of modality, which makes a lot of sense to me, especially in editors as complex as vim and emacs, which as you said, have so many functions.
eg. Moving around text in vim is much easier on the hands than moving around in emacs. , , , ? That’s crazy! I went and checked out the ergoemacs project, at least they admit that the default emacs bindings are crazy. They’ve tried to provide a reasonable remapping that keeps most of the functions available, but eases off on the most commonly used keystrokes. But that doesn’t come close with navigating on the home row _without modifier keys_.
Short of a kinesis foot pedal (which I am looking into, btw), I doubt I’ll be switching to emacs, much as I’d like to. I love my pinkies, I’ve had them for as long as I can remember.
May 19th, 2009 at 7:10 pm
Hey.. Nice Idea.We could have a footpedal(Two in fact) for Control and Alt. However, I have an extra muscle in my left little finger!
May 25th, 2009 at 5:38 pm
It’s definitely true that Vi and Vim have more ergonomic commands for basic and “dump” text editing. For example, Emacs’s C-f, C-b, C-n and C-p are just crazy. I’d like to suggest Ergo movement mode for more natural cursor-moving.
May 27th, 2009 at 6:04 pm
Lol! I’m still using gedit for everything. btw I’ve tagged you for the “7 random things” meme @ http://apnerve.blogspot.com/2009/05/7-random-things-about-me.html
May 29th, 2009 at 2:15 pm
Use Eclipse :D
June 23rd, 2009 at 2:20 am
Beware the Dark Side. Emacs leads to Lisp, Lisp leads to Scheme, and Scheme leads to gouging your eyes out with a sharp stick. :-P
I still use vim on all headless machines. Komodo Edit on my Desktop though.
I can see the power of extensibility in Emacs (E.G. Oralux – Speech-based Linux distro built on Emacspeak) I just refuse to use it.
November 13th, 2009 at 12:45 pm
>I’m talking about the concept of modality, which makes a lot of sense to me, especially in
>editors as complex as vim and emacs, which as you said, have so many functions.
Emacs is modal too. Just that the way you switch between modes is not as manual as it is in vim http://en.wikipedia.org/wiki/Mode_(computer_interface)#Examples
One *problem* with Emacs is that it is customisable. My .emacs.d has grown so much over the years that it’d be a nightmare for me if I lost it.
November 13th, 2009 at 5:23 pm
@Noufal: Nah, I wouldn’t call it a problem; It’d be a nightmare if I lost any of my dotfiles. Which is why I version it on GitHub: http://github.com/artagnon/dotfiles
November 16th, 2009 at 11:16 am
I do the same thing but I don’t think I’d need to be *that* paranoid with vim.