开发者

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

开发者 https://www.devze.com 2023-01-28 10:06 出处:网络
Is it possible to setup Vim so that it will only show: WARNING: The file has been changed since reading it!!!

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

精彩评论

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