在差异文件中使用vimdiff [英] use vimdiff with a diff file
问题描述
如何使用vimdiff查看差异文件中描述的差异?
How can I use vimdiff to view the differences described in a diff file?
推荐答案
而不是使用/usr/bin/vimdiff
命令,请尝试以下操作:
Instead of using /usr/bin/vimdiff
command, try this:
$ vim file
:vertical diffpatch path/to/diff
(简称为:vert diffpa
.)
这等效于在原始文件和随后修补的文件上调用vimdiff
,但是vim
为您在临时文件上调用patch
.
(: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.
如果您希望自动输入vim
的差异模式,请使用以下命令:
If you want vim
's diff-mode to be entered automatically, use this:
$ vim file +'vert diffpa path/to/diff'
其中+command
要求vim
执行命令". (+123
跳到第123行,+/abc
跳到"abc"的第一个匹配项,已全部记录在案.)
where +command
asks vim
to execute "command". (+123
jumps to line 123, +/abc
jumps to the first match for "abc", it's all documented.)
关于Ken的查询:如果diff文件中包含适用于您当前正在编辑的文件以外的文件的块,则无需担心; vim
调用下面的patch
可执行文件,该文件将询问这些神秘丢失的文件的位置,您可以告诉patch
跳过这些大块.
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.
这篇关于在差异文件中使用vimdiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!