检测文件更改,提供重新加载文件 [英] Detect file change, offer to reload file

查看:25
本文介绍了检测文件更改,提供重新加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用 gVim 进行编辑,但有时在远程连接到我的机器时使用 vim.

I normally use gVim for editing, but I sometimes use vim when remotely connecting to my machine.

当我在 gVim 中打开一个文件并且它从外部更改(例如来自存储库的新更新)时,gVim 提供重新加载它.

When I have a file opened in gVim and it has changed from outside (e.g. new updates from repository), gVim offers to reload it.

然而,当 Vim 发生这种情况时,它不会执行任何操作,直到您尝试保存文件.它只是警告您文件已更改,但不提供重新加载它.

However when such a thing happens with Vim, it does nothing until you try to save the file. It just warns you that file has changed, but does not offer to reload it.

是否有设置使 Vim 的行为与 gVim 匹配?

It there a setting to make Vim's behavior match gVim?

推荐答案

这是使用名为 FileChangedShell 的自动命令完成的.我太新,无法发布链接,但最好的办法是阅读 vim 文档的 autocmd 部分(Google 对此)

This is done using an auto command called FileChangedShell. I'm too new to post links, but your best bet would be to read the autocmd part of the vim documentation (Google for that)

但要点是在 vimrc 中设置类似以下行的内容

but the gist is to set something like the following line in your vimrc

:au FileChangedShell * echo "Warning: File changed on disk"

这篇关于检测文件更改,提供重新加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆