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?
KDiff3是开源的,可在多个平台上使用,包括Win32和Linux.
它具有Gishu讨论的关于Beyond Compare的"手动对齐"功能(顺便说一下,我没有亲自使用它,但被我认识的许多人认为是一个很棒的工具).
有关更多示例,请参阅此答案.
Vim 的有线插件适用于我.以可视方式选择文件的一个部分并键入:Linediff
.目视选择其他部分并键入:Linediff
.它会将vim置于vimdiff模式,仅显示您之前突出显示的两个部分.键入:LinediffReset
退出vimdiff模式.
更多信息:
https://unix.stackexchange.com/a/52759/32477
https://superuser.com/a/414958/199800