This question has been answered in StackOverflow: How does Vim's autoread work?
Solution 1
Follow explanations in Vim Wikia page Have Vim check automatically if the file has changed externally.
This solution requires the addition of a function to your vimrc file and that a new command is called on the buffers you want to watch.
Solution 2
This solution was proposed by @GregSexton in the question I linked above. The idea is to force the modification check whenever one of the following happens:
- Entering the buffer.
- No key was pressed for 'updatetime'
- Cursor moved.
You can find the code that implements this below:
augroup checktime
au!
if !has("gui_running")
"silent! necessary otherwise throws errors when using command
"line window.
autocmd BufEnter * silent! checktime
autocmd CursorHold * silent! checktime
autocmd CursorHoldI * silent! checktime
"these two _may_ slow things down. Remove if they do.
autocmd CursorMoved * silent! checktime
autocmd CursorMovedI * silent! checktime
endif
augroup END
Add and/or remove autocmd
as best suits your workflow. Check here for the list of events that can be used.
If autoread is also enabled, file will be automatically read if not modified:
set autoread
autoread
setting & it's limitations ... possibly this is also an answer for this question?