How to use vimdiff as the subversion diff tool
vimdiff is fantastic. Follow these instructions to make subversion use vimdiff when you run svn diff.
Get this diffwrap.sh script and save it anywhere. I saved mine in my $HOME/bin directory. Make sure to make it executable! I’m showing it below:
#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/bin/vimdiff"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}
# Call the diff command (change the following line to make sense for
# your merge program).
$DIFF $LEFT $RIGHT
# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.
Then change your $HOME/.subversion/config file to point at that script:
[helpers]
diff-cmd = /home/matt/bin/diffwrap.sh
Then go diff a file!
See this section of the svn book for all the details.
lojic.com » Blog Archive » Use vimdiff to display subversion diffs said,
November 27, 2007 @ 11:14 am
[...] I prefer using vimdiff or gvimdiff to view differences between files. When researching ways to allow using vimdiff to view subversion differences, I came across this article. [...]
Brian Adkins said,
November 27, 2007 @ 11:16 am
Just what I was looking for - thanks for the tip!
joel said,
April 8, 2008 @ 4:57 pm
great, but, any ideas on how to get the right pane to save changes over the top of your file if you move something from the repository version into your version? :\
matt said,
April 9, 2008 @ 9:10 am
Hi Joel, Yeah, I’ve wondered that myself too. I have no suggestions other than using :w to write out stuff to the file you want.
Let me know if you figure it out!