How to use vimdiff to replace the original SVN diff and git diff (efficiency improvement)

Time:2020-10-26

Many command line players often encounter a problem when developing under Linux. Whether it is SVN or git, the original diff function provided is too difficult to read. What we hope is to show the side by side contrast mode under the command line, rather than the inline mode. Here we provide a little trick to solve the problem of eye pain.

1. Vimdif replaces SVN diff

1) Script

Execute VIM diffwrap.sh , add the following content (input: I, then right-click to copy the original text and paste the content to the terminal)

#!/bin/sh

#Filter out the first five command line parameters of SVN diff

shift 5

#Compare files using vimdiff

vimdiff “[email protected]

2) Modify ~ /. Subversion / config to find the following configuration line:

# diff-cmd = diff_program (diff, gdiff, etc.)

It is amended as follows:

diff-cmd = /usr/local/bin/diffwrap.sh

Here you need to replace your address, it is generally recommended to diffwrap.sh Copy to / usr / local / bin /.

2. Vimdif replaces git diff

The default git diff is as follows:

1) Execute the following command on the command line to let git diff use the effect of vimdiff

git config –global diff.tool vimdiff

git config –global difftool.prompt false

git config –global alias.d difftool

2) How to use it

Execute git D README.txt Single view file

Execute git d to view all diffs. After reading, use: QA exits the current diff view and will automatically jump to the next one.

summary

This article on how to skillfully use vimdiff to replace the original SVN diff and git diff (efficiency improvement) article introduced here, more relevant vimdif to replace SVN diff and git diff content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!