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

时间:2010-11-29 01:37:12

标签: vim

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

WARNING: The file has been changed since reading it!!!

如果文件实际上不同,而不仅仅是时间戳发生变化?

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

1 个答案:

答案 0 :(得分: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中有一个bug)。

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

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

相关问题