有没有办法配置vimdiff忽略所有空白?

我使用vim -d file1 file2为了看到他们之间的差异。这工作正常,但我想忽略空白更改 – 它们与源代码文件无关。

Vim帮助说明以下命令会做的魔法:

set diffopt+=iwhite

但不幸的是,此命令只添加-b到diff工具命令行,并且只会忽略结尾的空格。 diff的正确命令行键应为-w,以忽略所有空格更改。但我找不到如何直接从Vim修改diff命令行。当然我可以编译一个自定义diff,或者用diff.sh替换diff,但是看起来有点丑陋:(。

有没有更好的方法来修改Vim如何与差异工具进行交互以显示文件差异?

是。像你一样设置iwhite选项,但另外,使diffexpr为空。

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

相关文章

解决方案:解决linux下vim乱码的情况:(修改vimrc的内容)全...
Linuxvi/vim所有的UnixLike系统都会内建vi文书编辑器,其他的...
      vim正则匹配:空行:/^$/  /^[\t]*$/注释...
$select-editorSelectaneditor.Tochangelater,run'sele...
上次手贱忘了保存,这次就简单做个备忘吧,把踩过的坑记一下...
Linux之文本编译器小结vim的优势所有的UNIX-LIKE习通都会内置...