How to set check interval for set autoread option in VIM

gvimvimvimrc

How can I set check interval for set autoread option in VIM? Is it possible?

Best Answer

The autoread option does not have a timer. A reload is triggered when a shell command is launched or checktime is executed. Furthermore, vim does not have built-in timer functionality, so there's no simple way (meaning without plugins or ugly hacks) to call checktime every n seconds.

You can misuse updatetime and events like CursorHold to execute checktime when no key is pressed for the configured time. That's not exactly the solution, but it comes close.

autocmd CursorHold * checktime

Note that this autocommand only triggers in normal mode, but I would say that makes sense in this case. You don't want to auto reload while you are typing.

Related Question