]> git.rmz.io Git - dotfiles.git/commitdiff
vim: check for file modifications automatically
authorSamir Benmendil <me@rmz.io>
Thu, 27 Aug 2015 00:35:31 +0000 (01:35 +0100)
committerSamir Benmendil <me@rmz.io>
Thu, 27 Aug 2015 01:33:49 +0000 (02:33 +0100)
vim/vimrc

index 0651305336a7e407f12526f075fb70e2e0e7f249..c74b75c6708e6fde68ec96b8a4bd44d140f69bc0 100644 (file)
--- 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 <space> and / to be <leader>