Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

vim - use vimdiff with a diff file

How can I use vimdiff to view the differences described in a diff file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of using /usr/bin/vimdiff command, try this:

$ vim file
:vertical diffpatch path/to/diff

(:vert diffpa for short.)
This is equivalent to calling vimdiff on the original file and the subsequently patched file, but vim calls patch on a temporary file for you.

Edit

If you want vim's diff-mode to be entered automatically, use this:

$ vim file +'vert diffpa path/to/diff'

where +command asks vim to execute "command". (+123 jumps to line 123, +/abc jumps to the first match for "abc", it's all documented.)

Regarding Ken's query: if the diff file includes hunks applying to files other than the file you're currently editing, no worries; vim calls the patch executable underneath, which will ask for the locations of these mysteriously missing files, and you can tell patch to just skip those hunks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...