Thursday, October 09, 2008

Use vimdiff as Subversion diff command



First create a script svbdiff inside the ~/.vim/scripts/ directory that contains the following


#!/bin/bash
shift 5;/usr/bin/vimdiff -f "$@"


and make it executable:


chmod +x ~/.vim/scripts/svndiff


Then create an alias in your ~/.bashrc file like:


alias svndiff="svn diff --diff-cmd ~/.vim/scripts/svndiff"


Now you can go to any Subversion repository and display file differences with


svndiff h264.c


The screenshot above shows the diff output of the h264.c of libavcodec. Make sure you have a color scheme that highlights the file differences. The screenshot above uses the inkpot color scheme.

2 comments:

  1. Anonymous6:38 PM

    FYI, after you create your svndiff script, instead of creating an alias in your .bashrc you can make sure ~/.vim/scripts/ is in your $PATH and add an entry to your ~/.subversion/config file like so:

    [helpers]
    diff-cmd = svndiff

    See the subversion manual for more info.

    ReplyDelete
  2. Thanks for the tip... I like this solution better!

    ReplyDelete