svn diff 使用 vimdiff 作为比较差异工具
转载自<http://www.coreymaynard.com/blog/improving-svn-diff-with-the-power-of-vim/>
One of vim's nice features is a powerful diff tool that can be used to easily tell the differences between multiple different files. This can be called up at any time by issuing the following:
vimdiff file1.xxx file2.xxx
Subversion's default diff tool - while effective - lacks a lot of options. Firstly, it simply outputs the results of the diff to standard out. This is limiting for several reasons: you can't edit the files you're diffing, so quickly changing code is impossible. There's also no color or syntax highlighting, so telling at a glance what's changed is more difficult. Vimdiff solves all these problems, as it drops you into a full instance of vim allowing you to do anything.
Why use svn diff when we can seamlessly integrate vimdiff into the workflow in two simple steps? Let's get started!
Step 1: The Script
The first thing that needs to be done is to create a simple bash script that will be the wrapper for svn diff. Create the following file on your system named diffwrap.sh:
#!/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
$DIFF $LEFT $RIGHT
You can either put it in a system wide folder (/usr/local/bin) or in your own folder. In any event, don't forget to
chmod a+x diffwrap.sh
Step 2: Make Subversion Use It
Now that the script exists, we have to tell Subversion to use it for diff. Luckily that's quite easy. Simply edit ~/.subversion/config and find the diff-cmd line inside the [helpers] section. Uncomment it and change it to something like this:
diff-cmd = /path/to/diffwrap.sh
Step 3: Profit!
You're all done! To see it in action, change directory into a Subversion project with some local changes, and simply diff like normal:
svn diff
关于vimdiff的简单使用:
[c 跳转到上一个差异项
]c 跳转到下一个差异项