在差异文件中使用vimdiff [英] use vimdiff with a diff file

查看:94
本文介绍了在差异文件中使用vimdiff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆