From Vim to Emacs

The other day pretty much out of the blue I decided to switch my main editor from Vim to Emacs. Well, it wasn’t totally random as these things are. I’ve had to write more Japanese lately and Vim just wasn’t cutting it.

I’ve been using Vim for several years now. Originally I started using Vim out of necessity. I was about to change jobs and would no longer be able to use Textmate as my main editor. I didn’t really know much about using editors back then. I started with Ruby on Rails and that pretty much sold me on using Macs and Textmate. I barely used Textmate for anything fancy other than the odd tab-completion and some odd snippets. I suppose that using whatever basic memo pad editor that comes with the computer wouldn’t have made much of a difference.

However, this being Japan and the chance of using a Mac for programming being quite slim I decided to switch to Vim. The idea was that I wouldn’t be bound to any platform and not have to relearn the use of an editor. At that point the choice came down to Vim or Emacs. Neither of them really appealed to me. I’ve had terrifying brushes with both and tried to stay away from them. With Vim I could get in but not get out. How do I enter something? How do I even quit this thing? With Emacs the key combinations looked like alien code that I couldn’t decipher. In the end I decided on Vim because once I figured out that I needed to be aware of the mode I was in (either navigation or input) then I could stumble with the rest.

Learning an editor like Vim didn’t really make me a better programmer. I did become proficient with keyboard navigation but I still wasn’t using all the features. I did love the fact that I had one setup that I could take with me everywhere. All you have to do is clone your settings directory with all your plug-ins and you could setup shop in a matter of days.

One thing that bothered me about Vim was the fact that inputting Japanese was simply not feasible at least for me. Basically, Vim and Japanese input are modal in nature. When you type Japanese you put in the spelling and then you convert it to the proper Chinese characters. So with Vim you have to go into input mode and then switch to Japanese input mode, convert it to the proper characters, switch out of it and exit input mode. Essentially I stopped writing Japanese.

Another thing was the setup. Although there are now good packages for using Vim out of the box like MacVim, getting the command line version to compile was a chore when setting up the proper ruby and Perl bindings, some things that certain features depended on. I definitely put in too many plug-ins trying to cover all the Textmate features it was missing. In order to extend Vim’s features you could learn an esoteric shell language exclusively written to extend Vim called Vimscript. It’s kind of like Bash but a bit worse. Some people wrote their plug-ins in ruby or Perl and added the bare basic wrappers in Vimscript. I kept a safe distance from it all.

Naturally, with all the plug-ins, including many of a dubious nature, my setup became a bit of a nightmare. Load was a bit slow and plug-ins that did complicated things like matching parentheses and indenting code didn’t quite work sometimes and just got in your way.

Having said that, navigation was quite a breeze and actually quite fun. I could stay on the home row and jump around a file with ease through a combination of letters and numbers. If I was to set things up today, I’m sure I would have less plug-ins and a more stable setup. However, it still wouldn’t make it easier to write Japanese with it. Even the best plug-ins would be limited in what they could do.

Emacs on the other hand doesn’t switch modes. You navigate and manipulate text with an assortment of finger-twisting commands that even gangstas in LA would have trouble performing. Have you ever tried pressing down control and the letter “v” at once? Or how about “ctrl x meta m” or something like that? To get anything done, you essentially press these crazy combinations all day. Of course, this isn’t as hard as it seems when you get used to it. In fact, it starts to become natural just like you go up and down in Vim with “j” and “k”. The only reason I was able to make the transition was by enabling sticky keys though. I press ctrl, meta and alphabets separately aside from the really easy to press ones.

The good thing is that I can navigate and execute commands without first catching myself on whether I’m in Japanese or English. I can do everything I do in English that I do with Japanese. I always wondered why a lot of the respected hackers in Japan used Emacs.

The amazing thing about Emacs is that it basically adopts a programming language Elisp at its core to extend functionality. It has its own Lisp language and interpreter built in! Once you start delving into Emacs, the things you can do are nothing short of astounding. You can surf the Internet, manage your calendar, read email, chat, irc, blog, twitter, gtd, and whatever crazy thing you can dream of. There’s an amazing group of elite hackers developing plug ins and even enhancing Emacs. After all these decades the core is still in active development even though the interface is essentially text.

I can say that after a couple weeks of tinkering with it, I’m constantly amazed at the things I can do with it. Even with a ton of plug ins loaded up it’s very responsive. Start up is slightly slower than Vim but not that noticeable, especially once your extensions are compiled (yes, you can compile extensions through Emacs). I’ve got everything from on the fly spell checking, indentation, intellisense like auto-complete, dictionary look ups, among a truckload of other things working for me like a charm.

Everything I need is right here. Even manuals are easily accessed and looking up functions are easy. It’s like a self-contained distraction-free text universe at your fingertips. The downside is that you could lose yourself for days twiddling with things and adding yet more features. The GTD system called “Org Mode” is probably the world’s most powerful yet flexible system with crazy integration. It takes a while to get to a point where you feel settled once you start discovering all this amazing features and messing with settings. I never thought I’d touch Elisp but I was writing some functions in a matter of days and pouring over code to get a feature just right or tracking down conflicts. That was an unexpected bonus.