Viewing svn diff result in vim

Warning: This blog post was written a long time ago and might be no longer relevant.

Some time ago I explained how to use colordiff to display svn diff's result in colors. You can do pretty the same with vim. It is specially useful when you have big amount of code to commit and it needs to be reviewed first. Vim makes navigating through it easier.

Viewing svn diff in vim

To view svn diff output in vim run:

svn diff lib/zWebBrowser.class.php | view -

view opens vim session in read only mode. This way you won't be asked whether you want to save the file on exit.

As you're going to use this command often, it's better to wrap it as a bash function. Add lines below to your ~/.bashrc file to load the function during login.

svndiff()
{
  svn diff "${@}" | view -
}

It will make the command shorter:

svndiff lib/zWebBrowser.class.php