Refresh all files in buffer from disk in vim

前端 未结 5 1705
予麋鹿
予麋鹿 2021-01-29 19:18

The command to refresh a file from version on disk is :e!

How can I do the same for all files in the buffer?

Background: I need that because I am u

5条回答
  •  孤城傲影
    2021-01-29 19:28

    From :help autoread:

    When a file has been detected to have been changed outside of Vim and it has not been changed inside of Vim, automatically read it again. When the file has been deleted this is not done.

    If, like me, you just want to always passively reload stale-but-unmodified buffers, then this seems like it should get the job done.

    However the final detail is when vim notices the stale buffer. That can be forced with checktime. If you have focus events set up, then we can run checktime whenever we gain focus like so:

    set autoread
    autocmd FocusGained * checktime
    

    This answer also has some interesting details.

提交回复
热议问题