Wednesday, March 9, 2011

Well, there's 10 hours I'll never get back

Sunday night, I'd decided to switch back to using Textmate. I'd given Vim a pretty good go. I'd installed a bunch of plugins and even gone as far as writing a bash script to load them when I went to a new machine.
But now I felt like I was spending more time thinking about Vim than I was thinking about the software I was writing. Basically, it just felt like too much mental effort.

Monday morning, I saw a reference to something called Janus. Not sure why I followed it but I'm glad I did. Carlhuda and Matsumoto have done a fantastic job configuring MacVim. They've turned it into the editor that I wanted all along.

They accurately describe Janus as a distribution. They didn't write Vim itself or MacVim or the plethora of plugins that are doing the heavy-lifting. They just bundled it together and made it just so. And they did a much better job than I'd managed to.

So now I don't have to forego the multi-windowed,  ubiquitous, open-source goodness that is Vim to get a beautiful full screen intuitive Rails development environment.

The only additions that I'd like to make (at this stage) are:

  • DBExt.vim: This is for performing raw SQL queries (remember those) in the editor and integrates very nicely with Rails.vim. Rails.vim provides a RDBExt command which takes as its only argument the name of an environment in the current Rails project. It creates a configuration such that any DBExt command will execute against the database for the nominated environment.
  • Some better integration with continuous testing frameworks like autotest. I'd like to jump to the last error detected with a key combination. This may already be possible. I just don't know how.
I also change some preferences and set up some key mappings in my .vimrc.local below:

This allows me to jump between buffers without having to save edits first (which I find annoying). It also maps some keys to perform some common rake tasks. For example, \sm (assuming \ is your leader character) will run the model specs.

If you're not familiar with it already, gf jumps to the filename currently under the cursor. Rails.vim extends this to be more Rails aware. Here we're mapping gf! to force the creation of the file if it doesn't already exist. Note, if you're too slow with the ! then vim will assume you mean gf and then fail to create the file. I kind of like that element of realtime in my text editor.

Janus has convinced me to stick with Vim, at least for now. It's also taught me to look harder for existing solutions before building my own.