将 vimdiff 与 diff 文件一起使用 [英] use vimdiff with a diff file

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

问题描述

如何使用 vimdiff 查看差异文件中描述的差异?

解决方案

不要使用 /usr/bin/vimdiff 命令,试试这个:

$ vim 文件:vertical diffpatch path/to/diff

(:vert diffpa 简称.)
这相当于在原始文件和随后打补丁的文件上调用 vimdiff,但是 vim 会为你在临时文件上调用 patch.>

编辑

如果你想自动进入 vim 的差异模式,使用这个:

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

where +command 要求 vim 执行命令".(+123 跳转到第 123 行,+/abc 跳转到abc"的第一个匹配项,全部都有记录.)

关于 Ken 的查询:如果 diff 文件包含应用于当前正在编辑的文件以外的文件的大块头,不用担心;vim 调用下面的 patch 可执行文件,它会询问这些神秘丢失文件的位置,你可以告诉 patch 跳过那些大块头.

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

解决方案

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.

这篇关于将 vimdiff 与 diff 文件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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