From: Samir Benmendil Date: Thu, 27 Aug 2015 00:35:31 +0000 (+0100) Subject: vim: check for file modifications automatically X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/ac83ce247dd25fa01d0b113c8294ee7bc5fb5428?ds=inline vim: check for file modifications automatically --- diff --git a/vim/vimrc b/vim/vimrc index 0651305..c74b75c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -299,6 +299,24 @@ augroup cursor_pos \ endif augroup END +" Check for file modifications automatically {{{2 +" (current buffer only) +" Use :NoAutoChecktime to disable it (uses b:autochecktime) +fun! MyAutoCheckTime() + " only check timestamp for normal files + if &buftype != '' | return | endif + if ! exists('b:autochecktime') || b:autochecktime + checktime % + let b:autochecktime = 1 + endif +endfun +augroup MyAutoChecktime + au! + au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime() +augroup END +command! NoAutoChecktime let b:autochecktime=0 +command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime + " bindings {{{1 " allow both and / to be