当前位置:   article > 正文

svn diff 使用 vimdiff 作为差异比较工具_no svn diff tool configured.

no svn diff tool configured.

svn diff 使用 vimdiff 作为比较差异工具


引用的一篇文章说明

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

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的使用

vim -d a.txt b.txt
vimdiff a.txt b.txt

快捷键说明
[c跳转到上一个差异项
]c跳转到下一个差异项
zo展开折叠的相同代码
zc重新折叠
dp把当前处的差异项复制到另一个文件
do将另一个文件的差异项复制到当前文件

作者 @AdvocateOS_CoderD
2015 年 02月 12日

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/694737
推荐阅读
相关标签
  

闽ICP备14008679号