加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 16:24:02 所属栏目:安全 来源:网络整理
导读:我使用vim -d file1 file2为了看到他们之间的差异。这工作正常,但我想忽略空白更改 – 它们与源代码文件无关。 Vim帮助说明以下命令会做的魔法: set diffopt+=iwhite 但不幸的是,此命令只添加-b到diff工具命令行,并且只会忽略结尾的空格。 diff的正确命
我使用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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读