bairui

Poor Man's Timer in Vim

Jul 3rd, 2011
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.45 KB | None | 0 0
  1. let s:lasttime = reltime()
  2. let g:tick_seconds = 2
  3.  
  4. function! Tick()
  5.   let l:now = reltime(s:lasttime)
  6.   if l:now[0] > g:tick_seconds
  7.     let s:lasttime = reltime()
  8.     call TickCallback(l:now[0])
  9.   endif
  10. endfunction
  11.  
  12. function! TickCallback(time)
  13.   echomsg "writing file since " . a:time . " seconds."
  14. endfunction
  15.  
  16. au CursorHold    *  call Tick()
  17. au CursorHoldI   *  call Tick()
  18. au CursorMoved   *  call Tick()
  19. au CursorMovedI  *  call Tick()
Advertisement
Add Comment
Please, Sign In to add comment