reloading externally modified buffers in vim
Any non-trivial software project will have multiple people editing the same file at roughly the same time. While conflicts are managed with the help of a version control system like git, you're still left with a problem at the editor level: files opened during a "git pull" being modified by the merge. Here's an attempt to solve this using vim.
The most intuitive way to handle it is to save all the buffers prior to pulling new commits that have the potential to change those files outside the editor, and reload them all afterwards. Vim makes it easy to reload an individual buffer with the ':e' command, but with 10-15 buffers it becomes frustrating. A better approach is to reload all the buffers at once with a single command and this is exactly what ':checktime' does. I have 'set autoread' in my ~/.vimrc so it won't prompt me for anything if all the buffers have been saved prior to the external modification. Nor will it do anything behind my back as the "auto" part suggests. The buffer reloading happens only if I issue a ':checktime'. Perfect solution.
So to resume the steps:
- save all the buffers in vim
- git pull
- :checktime
- rinse, repeat



Discussion
I'm new to VIM, isn't this what the "set autoread" command in my .vimrc does? (I use MacVIM)
It's not enough. You need to trigger the reloading with :checktime whenever you need it.
Leave a Comment :
Leave a Comment