答案1
你可以通过以下方式实现大部分功能
:set autoread
从:h autoread
*'autoread'* *'ar'* *'noautoread'* *'noar'*
'autoread' 'ar' boolean (default off)
global or local to buffer |global-local|
{not in Vi}
When a file has been detected to have been changed outside of Vim and
it has not been changed inside of Vim, automatically read it again.
When the file has been deleted this is not done. |timestamp|
If this option has a local value, use this command to switch back to
using the global value: >
:set autoread<
因此这将使其自动读取除非你有本地修改。这是为了防止您丢失工作。
如果您希望它自动读取而不管是否有本地更改,您可以设置一个自动命令:
autocmd FileChangedShell * e! %
然而,这很可能会让你失去工作,所以我强烈建议不要这样做。