Friday, September 10, 2010

Vim in IRB with Utility Belt

One of the most useful things I ever did was giving my IRB gem Utility Belt the ability to edit Ruby in vi and run it in the IRB REPL. Essentially, you can go into vi from IRB, and exit back out to IRB when done. Likewise with TextMate and emacs, and conceivably any other editor that runs in a Unix-y way.

Here's a four-minute video. Fair warning, it has some flaws; it's quite a bit vague, it begins with some kind of unfortunate audio mishap, and it includes a bit of Fizzbuzz fail. But it showcases a technique which made me more productive and made programming a lot more fun for me.



I made this because I got an e-mail about it that made me wonder why I never made a video about it before. Then I remembered that Vimcasts also did a video about this.

By the way, the history on this is kind of fun. I did a presentation in 2007 where I just live-coded and demo-ed all the great gems and hacks out there for IRB and Rails console at the time. Somebody asked me if it would be possible to do this vi thing, in the Q&A bit at the end of my presentation, and I coded it up on the spot. Afterwards, Greg Brown helped me figure out a much better implementation.