Eug*_*ash 10
将这些行添加到您的.vimrc:
au FocusGained,BufEnter * :silent! checktime
au FocusLost,WinLeave * :silent! w
Run Code Online (Sandbox Code Playgroud)
基本上,当Vim或当前缓冲区获得焦点时,检查并重新加载(或丢弃)外部更改,并且可选择在离开焦点时自动保存.
资料来源:Vim Wiki.
今天我发现了一个与这个问题相关的有趣发现......
隐藏在/usr/share/vim/vim71/vimrc_example.vim这里有这个命令:
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
Run Code Online (Sandbox Code Playgroud)
它将打开一个vimdiff类似于当前缓冲区和底层文件的窗口,突出显示两者之间的所有变化.