From ac83ce247dd25fa01d0b113c8294ee7bc5fb5428 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Thu, 27 Aug 2015 01:35:31 +0100 Subject: [PATCH] vim: check for file modifications automatically --- vim/vimrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 -- 2.48.1