Vim:如果内容不同,则仅显示"文件已更改"警告

Dav*_*ver 13 vim

是否可以设置Vim,以便它只显示:

WARNING: The file has been changed since reading it!!!
Run Code Online (Sandbox Code Playgroud)

如果文件实际上不同,那么不仅仅是时间戳改变了吗?

例如,我经常背景Vim(^ Z),回滚到文件的旧版本(例如,针对它运行测试套件),fg再次恢复到当前版本和Vim ......但我仍然得到"文件已更改"警告,因为即使内容相同,时间戳也已更改.

Xav*_* T. 6

如果你试试vim 7.3

:help timestamp

有人说
When Vim notices the timestamp of a file has changed, and the file is being edited in a buffer but has not changed, Vim checks if the contents of the file is equal. This is done by reading the file again (into a hidden buffer, which is immediately deleted again) and comparing the text. If the text is equal, you will get no warning.

所以我想在你的情况下,除了文件时间戳之外发生了一些变化(或者Vim中存在一个错误).

在我的情况下,我经常在签出文件时收到该消息:即使内容没有改变,它们也会从"只读"变为"读写".

所以我想如果文件的属性受到影响,即使内容相同,也会被视为"已更改".