jtimberman's Code Blog

Chef, Ops, Ruby, Linux/Unix. Opinions are mine, not my employer's (CHEF).

Switching to GNU Emacs

I have a confession to make.

For those who follow me on Twitter, you already know. For those who read the title of this post, you can make an educated guess.

After ~16 years of using Vi/Vim/MacVim, I’m switching my primary editor to Emacs. Over the years, I have tried to use Emacs without much progress. I never really gave enough effort to learn it. In fact, only in the last year did I learn all the movement keys (C-f, C-b, C-n, C-p). To say I made uneducated disparaging comments about Emacs would be an understatement.

I have a highly customized Vim/MacVim setup, with lots of bells and whistles like NERDtree, Command-T, language plugins and more derived from Adam Jacob’s repository. I’ve spent countless hours tweaking and customizing it further to enhance productivity.

So how did I come around and completely switch editors? It wasn’t easy, that’s for sure. First there’s the resistance to a new tool. However, I wanted to keep a truly open mind, and give it a real, honest attempt. I bought the O’Reilly Learning GNU Emacs book and started reading, with the editor open to one of my favorite things to edit, my ~/chef-repo.

Actually the first thing I did was get a sensible and sane configuration started. I forked Phil Hagelberg’s excellent Emacs Starter Kit. I also thought AquaMacs would be the sensible place to start, since I’m using a Mac, and it uses a lot of familiar OS X hotkeys for copy/paste, opening and closing tabs and more. However, some fellow Opscode coworkers advised against AquaMacs, especially with the starter kit, because it leads one down a path of really “non-standard” Emacs settings. That isn’t entirely awful, since I manage my workstation(s) with Chef and have my Emacs config available first thing on a new machine (now that its added in, anyway :)). However, I quickly became annoyed with some erratic behavior. For example, opening a tab, then having something like a completion window means that switching tabs will keep the completion window persisted, even though it was split on “a different tab”. 

So I switched to GNU Emacs, and have been using that for the last week. I have no measure of whether my productivity is increased or not, but I’m getting pretty comfortable with the editor, and able to do most of what I was really good at in Vim. I sometimes miss Command-T, but the default Emacs file fine (C-x C-f for those that don’t know) is really good. Some of the things that I have found to be totally essential and are what keep me using the editor:

Buffers are totally sane, very fast to switch between, and easy to navigate between open files. Also related, the half hour or so I spent learning and practising the basics - create horizontal and veritical split, opening files in new windows, and more was totally worth it. I’m actually getting to be faster than the panels used in Vim, which I’ve been using for ~4 years.

File navigation is awesome. I really liked ”-T” in the short time I used TextMate, and I loved FuzzyFileFinder and Command-T plugins for Vim. However the flexiblity of the built-in default file navigation in Emacs is really intuitive for me.

With the Emacs starter-kit, some good modes are installed and available by default without modification. Most of the time I’m using Ruby, Markdown or Javascript modes. I anticipate starting in on org-mode at some point, but as I’m still getting comfortable with the basics, we’ll take some baby steps :).

Emacs really is easy to customize. I never really did much with Vim. I certainly cargo culted other configs, went with what worked, and left it at that. With Emacs, I’m doing that, but the code I’m looking at is more sensible to me. I hope this doesn’t mean I’m going to go learn Lisp :). As I’ve forked emacs-starter-kit on GitHub, and made my own customizations, I’m also sharing those back on the site, so if you want to see what changes I’ve made and additional modes I’ve installed, take a peek. If you look, there’s a chef.el the “jtimberman” directory with some shortcuts to drop off common Chef resources. As I learn more, I plan to make that a bit more useful as snippets or maybe even a chef-mode.

Speaking of custom modes, even if I didn’t use it for anything else, Emacs is totally worth using for confluence-mode. We have two Confluence wikis, one for Chef, and an internal company wiki. Confluence mode seems to assume you only have one wiki, and I haven’t sorted out the details on how to easily switch between the two. For now I just put the confluence-url setting in the *scratch* buffer and do M-x eval-region to “switch”. That said, the ability to quickly search for a page and load the confluence wiki markup page in a buffer, then save the content back out to the wiki directly is *awesome*. No more 4 step process to copy/paste the markup into an editor window and back out to the form. Also, while there’s a Vim syntax plugin for Confluence, I had no end of error trying to use it.

As I’ve only been using Emacs for a week, I’m still a novice. However, I’ve gotten to the point where I can get what I need done in writing Chef cookbooks and documentation. I’m enjoying the learning process, and pleased that I’m at a point where the editor is not only out of the way, but helping me get more done.

The potential to devolve into an editor war is high, so please, no comments about how other editors are better or that I should switch back to Vim. I firmly believe that everyone should use tools that they enjoy, and that help them be productive. Snarky comments can be made on twitter, of course :).