我使用vim -d file1 file2为了看到他们之间的差异。这工作正常,但我想忽略空白更改 – 它们与源代码文件无关。
Vim帮助说明以下命令会做的魔法:
set diffopt+=iwhite
但不幸的是,此命令只添加-b到diff工具命令行,并且只会忽略结尾的空格。 diff的正确命令行键应为-w,以忽略所有空格更改。但我找不到如何直接从Vim修改diff命令行。当然我可以编译一个自定义diff,或者用diff.sh替换diff,但是看起来有点丑陋:(。
是。像你一样设置iwhite选项,但另外,使diffexpr为空。
原文链接:https://www.f2er.com/bash/391032.html从vim docs的相关部分:
iwhite
Ignore changes in amount of white space. Adds
the “-b” flag to the “diff” command if
‘diffexpr’ is empty. Check the documentation
of the “diff” command for what this does
exactly. It should ignore adding trailing
white space,but not leading white space.
还要注意,您可以通过设置diffexpr提供一个自定义diff命令行。参见关于vimdiff man page的讨论,特别是:
The ‘diffexpr’ option can be set to use something else than the standard
“diff” program to compare two files and find the differences.When ‘diffexpr’ is empty,Vim uses this command to find the differences
between file1 and file2:06000