是否可以设置 Vim 使其仅显示:
WARNING: The file has been changed since reading it!!!
如果文件实际上不同,而不仅仅是时间戳更改时?
例如,我会经常后台 Vim (^Z),回滚到文件的旧版本(例如,针对它运行测试套件),恢复到当前版本和
fg
Vim 再次......但我仍然收到“文件已更改”警告,因为即使内容相同,时间戳也已更改。
最佳答案
如果您尝试使用 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 中有一个错误)之外,其他东西已经改变了。
就我而言,当我 checkout 文件时,我经常收到这样的消息:即使它们的内容没有改变,它们也会从“只读”变为“读写”。
所以我猜如果文件的属性受到影响,即使内容相同,它也会被视为“更改”。
关于Vim:如果内容不同,则仅显示 “file has been changed” 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4300253/