Tenderlove Making

Autotest and Vim integration

Yay! I got vim and autotest integration working. When I run autotest, if there is an error, I can have Vim read the errors from autotest and jump me to the right place.

Here is a video of me using it:

</param> </param> </param> </param></embed>

Please note that I’m not copying and pasting anything. In vim, I hit a command and Vim automatically picks up errors from autotest and jumps me to the line where the error occurred.

You too can impress your friends with this trick! Here’s how:

  1. Make sure you have vim-ruby installed
  2. Use this as your .autotest file: ~~~ ruby require 'autotest/restart' Autotest.add_hook :initialize do |at| at.unit_diff = 'cat' end Autotest.add_hook :ran_command do |at| File.open('/tmp/autotest.txt', 'wb') { |f| f.write(at.results.join) } end ~~~
  3. Add this to your .vimrc: compiler rubyunit nmap <Leader>fd :cf /tmp/autotest.txt<cr> :compiler rubyunit<cr>
  4. </ol> Now when you get an error in autotest, just type "\fd" in Vim to jump straight to your first error. The contents of /tmp/autotest.txt will be used in your errorfile. In Vim do ":help quickfix" for more info on what you can do with your new found power. Caveat: You don't get unit_diff. I'm working on that. Any help would be much appreciated (I suck at errorformat in Vim).
« go back