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:

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:

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

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