How to Autoreload File in Vim Without using :edit
Background
- Vim store files inside an in-memory “buffer” which is presented to the user
- If another program modifies the file that Vim is working with (e.g. another Vim session or IDE), Vim will not reload the contents of the file into the buffer by default
Steps
- To enable the reloading behaviour you need to set the
autoread
option in your.vimrc
totrue
- Example Neovim configuration
-- options.lua
local options = {
-- Snipped for brevity
autoread = true
}
- Or just plain Vimscript:
set autoread