开发者

Vim: Only show “file has been changed” warning if content is different

Is it possible to setup Vim so that it will only show:

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

If the file is actually different, not just when the timestamp changes?开发者_如何学JAVA

For example, I'll quite frequently background Vim (^Z), roll back to an older version of a file (eg, to run the test suite against it), revert back to the current version and fg Vim again… But I still get the “file has changed” warning because, even though the content is identical, the timestamp has changed.


If you try on vim 7.3

:help timestamp

It is said that
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.

So I guess that in your case, something has changed other than the file timestamp ( or there is a bug in Vim).

In my case, I often get that message when I check out files : they change from "read only" to "read write" even if their content has not changed.

So I guess that if the properties of a file are affected, it is considered "changed" even if the content is the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜