25 Dec 2012

RCodeTools - How to get them working in VIM

RCodeTools is an add-on for popular neckbeard text editors such as VIM and Emacs. (My preference currently being VIM). I came across it through RubyTapas Screencasts by Avdi Grimm. He uses it extensively in his screencasts for crystal clear explanations and live displays of code execution.

RCodeTools adds hash comments (ie #=\>) to the text editor buffer. Then when another command is executed, the whole buffer is evaluated and the area beyond the hash comment is populated with the output from that specific line(s) of code.

It’s remarkably helpful for explaining and demonstrating code because it avoids any context shift. The comments serve to demonstrate the code’s state at any given moment!

Avdi Grimm uses RCodeTools inside Emacs in the screencasts and I was eager to begin using RCodeTools myself. I had difficulty getting the plugin to work in VIM, resulting in attempts to reinstall VIM, modify the $PATH, etc.

Turns out there is a simpler way: 1. Install RCodeTools into your ~/.vim/ folder. Specifically this means the vimscript files. 2. Install vim-rvm for managing path. 3. Gem install rcodetools inside your standard RVM ruby. 4. Add mappings to VIMRC. Included are my mappings (which are recommended by the README.vim)

I look forward to putting this addon to good use at future CodeRetreats! And it’s the perfect compliment to screencasting.

Thanks Avdi for drawing my attention to this wonderful tool.