如何区分同一文件的两个部分? [英] how can I diff two sections of the same file?

查看:96
本文介绍了如何区分同一文件的两个部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个相似但又不同的部分的源文件.我想将两个部分合并为一个带有处理细微差异的参数的子例程,但是我需要确保我了解它们,因此我不会错过任何一个. 在这种情况下,我通常要做的是将每个部分复制到一个单独的文件中,然后使用tkdiff或vimdiff突出显示差异.有什么方法可以跳过中间文件,而只比较同一文件的两个部分?

I have a source file with two similar yet subtly different sections. I'd like to merge the two sections into one subroutine with a parameter that handles the subtle differences, but I need to be sure I'm aware of them all so I don't miss any.
What I usually do in such cases is copy each of the sections to a separate file and then use tkdiff or vimdiff to highlight the differences. Is there any way to skip the intermediate files and just diff two parts of the same file?

推荐答案

linediff Vim插件对我来说效果很好.可视地选择文件的一部分,然后键入:Linediff.可视地选择另一部分,然后键入:Linediff.它将把vim置于 vimdiff 模式,仅显示您先前突出显示的两个部分.键入:LinediffReset退出vimdiff模式.

The linediff plugin for Vim works well for me. Visually select one section of your file and type :Linediff. Visually select the other section and type :Linediff. It will put vim in to vimdiff mode, showing only the two sections you highlighted previously. Type:LinediffReset to exit vimdiff mode.

更多信息:

https://unix.stackexchange.com/a/52759/32477

https://superuser.com/a/414958/199800

这篇关于如何区分同一文件的两个部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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