refresh changed content of file opened in vi(m)
I have a config-file that I keep open in vim, but that sometimes gets changed on disk, without these changes being reflected on the terminal. Can I refresh the content on the screen without closing and re-opening the file? If so, how?
Wrap up: all the answers so far are of "Poll" instead of "Push" style. That is, instead of receiving an external file change event like it was done by other software's similar features, these answers rely on vim actively polling the file change, either manually or triggered by a user action or a timer. The end result is you won't see change refreshed on screen instantaneously.
You can use the
:editcommand, without specifying a file name, to reload the current file. If you have made modifications to the file, you can use
:edit!to force the reload of the current file (you will lose your modifications).
:editcan be abbreviated by
:e. The force-edit can thus be done by
@StephaneChazelas: Yeah,That's correct :) @twan163: Instead of `:edit` and `:edit!` you can use `:e` and `:e!` respectively.
@gerrit: Lose modifications, Definitely yes :) But you can recover the lost modifications by `u`ndoing. :)
`:w|e` **w**rite *and* **e**dit (reload) :)
`|` is for chaining commands, and can be interpreted as *then* executing commands in sequential order.