How does Vim's autoread work?

后端 未结 7 1670
[愿得一人]
[愿得一人] 2021-01-30 10:13

:h autoread says:

When a file has been detected to have been changed outside of Vim and it has not been changed inside of Vim, automatically

7条回答
  •  感情败类
    2021-01-30 10:41

    Outside of gvim, autoread doesn't work for me.

    To get around this I use this rather ugly hack.

    set autoread
    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
    

    This seems to be what the script irishjava linked to does, but that lets you toggle this for buffers. I just want it to work for everything.

提交回复
热议问题