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.
Actually, as is often the case with vim, if you can think of the feature, someone has probably implemented it.
In this case, you are probably looking for the Colorizer plugin. Note that though this plugin “works best” with gvim, it supports 88 and 256 color terminals.
From the script site:
The idea is to highlight color names and codes in the same color that they represent.
The plugin understands the W3-Colors (used for CSS files for example), the Color names from the X11 Window System and also codes in hex notation, like #FF0000 (which represents Red in the RGB color system). Additionally, it supports the CSS color specifications, e.g. rgb(RR,GG,BB) color representation in either absolutely values or as percentage and also the HVL Color representation like hvl(H,V,L)
Edit: You did not mention what operating system you're using, but the installation is fairly straight-forward even if done manually. However, if you are using Arch Linux, I packaged this plugin and it is available for installation through the AUR.
Best Answer
The
autoread
option does not have a timer. A reload is triggered when a shell command is launched orchecktime
is executed. Furthermore, vim does not have built-in timer functionality, so there's no simple way (meaning without plugins or ugly hacks) to callchecktime
everyn
seconds.You can misuse
updatetime
and events likeCursorHold
to executechecktime
when no key is pressed for the configured time. That's not exactly the solution, but it comes close.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.