Selecting an editor


5 February 2011 · editors · vim · newbie

The flame wars on the topic of editors have probably been around since, well, there was more than one editor to choose from! An IDE or an editor is such a fundamental tool for a developer that it is no wonder we end up having very strong views on our editor of choice. What I have never really understood is why we also tend to have strong negative opinions on editors that we choose not to use — live and let live people! This post is about my journey through the process of selecting an editor — I also present a few tips and resources along the way, particularly on Vim (the editor I settled on). I am not in the slightest bit interested in fuelling the aforementioned flame war; if I say something here that could be interpreted as an insult to your favourite editor, please keep my motivation in mind and resist the temptation for such interpretation. Oh and I work on OS X so some editors mentioned here may not apply to your environment, sorry.

Background

I learned to write code in 1987 on green screen terminals hooked up to a VAX. We were introduced to vi and I used it on a daily basis for a couple of years. No wonder I’ve got some of the basic vi commands baked into my brain stem! We moved on to using NeXT and Apollo workstations and I got to use editors that allowed you to click around with a mouse. Then came many years of using pencil, paper, chalk and blackboards, followed by the terrible years of only ever writing documents using MS Word and PowerPoint. So, until recently I hadn’t touched a developer’s editor in a very long time.

When I started writing code again I noticed that TextMate, Emacs and Vim were the main contenders in the Rails community. I decided fairly early in the piece to try and give each editor a good month of serious use so that I could, with some objectivity, find the right one for me. If you are starting out as a developer, I highly recommend this approach.

Foreground

And here is how it went. TextMate was the easiest to work with then because I could just use the OS X shortcuts that were in muscle memory and use my mouse to click around etc. When my TextMate trial ran out I looked around again and found AquaMacs – a version of Emacs for OS X that, well, allows you to edit at will and not use very many Emacs commands at all! Jokes aside, it mashes together Emacs with a Mac look-and-feel but this does get in the way of forcing any sort of discipline on oneself to learn Emacs. This opinion piece from Stack Overflow treats this topic quite well.

When I started my job I felt a lot of pressure to not be learning supporting tools like editors and instead, becoming immediately productive! This was laughable in hindsight really because I had nothing over an enthusiast’s understanding of Rails at this point and needed to really just learn for a while! My very awesome colleagues got this of course and encouraged the learning process, all the while nudging me ever so firmly towards getting a solid mind meld happening with my operating environment. I went back to TextMate for a short while but then followed the chosen platform of two of my co-workers and adopted the Carbon build for Emacs. I did this with the very awesome emacs-starter-kit and then things got really good! I spent a month with Emacs and watched my productivity increase.

Vim

And then the circle closed. Before I started, my dev team consisted of two Emacs users and one Vim devotee. Right about when I was finishing my month with Carbon Emacs, a new guy joined the team and brought the Vim users count up to two. At about this time I read the mighty Yehuda Katz on his journey from TextMate to Vim and decided to give MacVim a go. And that’s where I’ve settled! Why? Well, I really like the speed with which I can move around a Rails project with Tim Pope’s terrfic Rails.vim plugin (I am told that there are similar plugins for Emacs) and I like the ease with which plugins like NERDTree allows me to look at my filesystem. Most of all, Vim commands just fit better with my brain – I like that they are about movement around a buffer and that they seem to consistently build on this philosophy. It just seems to work for me I suppose, and I think it’s because I still carry some basic vi in my brain stem!

I’m very much a novice but I am comfortable with my environment and I am hungry to learn more. Here are some resources that I have found very useful thus far —

General reference and tutorials:

  1. Efficient editing with Vim – Stellar article that is intended to help vi novices develop their skills so that they can use vi efficiently. It focuses on movements, the core of Vim commands
  2. Use Vim like a Pro – comprehensive tutorial on some 38 different topics
  3. Graphical vi-vim Cheat Sheet and Tutorial – indispensable cheat sheets with accompanying tutorials

Posts and screencasts that cover plugins and really make the connection with development come to life:

  1. Steve Losh, Coming Home to Vim – well written and packed with pointers on plugins and vimrc customisations. Steve’s not a Rails guy (Python and Django I think) so nothing to do with Rails
  2. Ben Orenstein’s screencast, Vim for Rails Developers. Recently I was looking around for a screencast that would show me how a seasoned Rails developer uses Vim and I came across Ben’s work and the Smash into Vim series by peepcode. I tried out the sample from peepcode and found the celebrity narrator’s style to be a bit off-putting (just a personal thing, I’m sure the ‘cast lives up to the high peepcode standard). Looked around at Ben’s stuff and found that he is a Rails developer, Vim obsessive and an efficiency junkie! Ben asks bloggers to contact him for a copy of his screencast in exchange for a review and this is what I did. I am happy to say that I was grinning like a Cheshire cat 10 minutes into the screencast and I only got happier as it went on. What about the first 10 minutes? Well, passionate as he is about efficiency, he starts off by spending (perhaps a tad too much) time on the topic of speed typing. It’s great advice, and it’s possibly the only part of the screencast that will apply to the complete Vim novice (if you don’t know the basics you won’t find them here). He really hit the sweet spot for me when he shows us how to effectively use Tim Pope’s Rails plugin. I use this plugin too but it became clear to me that I had only been using about 5% of its features! Boy is my productivity about to go up! Ben also takes us through the use of snippets, ctags and the surround plugins, spends some time on the wonders of ack and how to use it from within Vim, and closes with some general tips and tricks. Something to keep in mind is that Ben appears to be a Vim purist – he works within his terminal and does not use any of the bells and whistles that come with MacVim. No mice are touched at all during this screencast! All in all, I heartily recommend his screencast to the not-so-new-to-Vim Rails developer — well worth the $11.99 price tag I think!

Plugins – use them wisely

I’m not going to do the traditional thing of offering my vimrc and plugin list because I’m just using janus (give or take a plugin or two). Janus is a vim-starter-kit for Rails types that has been put together by that mythical Carlhuda! Modifications in my local gvirmc come mainly from things I have borrowed from Steve Losh’s article (referenced above).

I asked Ben for a comment on janus and this is what he had to say:

Actually, I’m not sure I’d recommend something like janus. The basic editor has so much built-in functionality that there’s already plenty to learn when you start out. Additionally, new users won’t know if certain behaviors are vanilla vim or accomplished through add-ons. Personally, I’d recommend new users go a couple weeks with no plugins. Start tweaking your vimrc to see learn what kind of customizations you can make. Then start adding plugins one at a time and mastering them slowly.

I’ll leave it up to you to figure out whether to pick up MacVim with janus and try out Vim … or whether you should do penance with the editor itself before adopting the gui version and plugins. I think it will depend a bit on whether you are the type that regards a solid understanding of a tool to be a pre-condition to using it, or, whether you are happy to get to the most productive environment as quickly as possible. I’ve chosen a middle ground – I’m mainly using Rails.vim and basic editor commands and gradually picking up what the other plugins in janus do.

In any case, that’s the story of how I ended up in smit with Vim. I hope you find some benefit from this post — good luck with the process of selecting an editor and making it your own!

Update (Oct 2011): Been using vim for a while now and am no longer using janus. My .vim is now on my github – forked from the remarkable Damien Le Berrigaud (vim superhero!), and updated with a few personal touches.
blog comments powered by Disqus