vtimer.vim: 1.0
解决了上一篇所说的问题, 上传到了vim.org: 这里
code:
1 "========================================================================= 2 " 3 " FileName: vtimer.vim 4 " Describle: automatic timer to measure time spent with vim 5 " Commands: :Showtime 6 " show total time used 7 " :Resettime 8 " reset total time 9 " 10 " Author: leaforestd 11 " Email: leaforestd@gmail.com 12 " 13 " Created: Sat May 12 07:51:25 CST 2012 14 " Version: 1.0 15 " History: 1.0 | leaforestd | Sat May 12 07:51:25 CST 2012 | first released 16 " 17 "========================================================================= 18 " 19 "===========================totaltime===================================== 20 "0 21 "========================================================================= 22 23 function! Vtimer_enter() 24 let s:v_start = localtime() 25 endfunction 26 27 function! Vtimer_leave() 28 let s:v_add = localtime() - s:v_start 29 let s:v_file = readfile($HOME.'/.vim/plugin/vtimer.vim') 30 let s:v_total = str2nr(strpart(s:v_file[19],1)) 31 let s:v_total = s:v_total + s:v_add 32 let s:v_file[19] = '"'.s:v_total 33 call writefile(s:v_file, $HOME.'/.vim/plugin/vtimer.vim') 34 endfunction 35 36 function! Vtimer_show() 37 let s:v_add = localtime() - s:v_start 38 let s:v_total = str2nr(strpart(readfile($HOME.'/.vim/plugin/vtimer.vim')[19],1)) 39 let s:v_total = s:v_total + s:v_add 40 let s:v_h = s:v_total / 3600 41 let s:v_m = (s:v_total % 3600) / 60 42 let s:v_s = s:v_total % 60 43 echo s:v_h . 'h ' . s:v_m . 'm ' . s:v_s .'s' 44 endfunction 45 46 function! Vtimer_reset() 47 let s:v_file = readfile($HOME.'/.vim/plugin/vtimer.vim') 48 let s:v_file[19] = '"0' 49 call writefile(s:v_file, $HOME.'/.vim/plugin/vtimer.vim') 50 endfunction 51 52 autocmd VimEnter * call Vtimer_enter() 53 autocmd VimLeavePre * call Vtimer_leave() 54 55 command! Showtime call Vtimer_show() 56 command! Resettime call Vtimer_reset()
ps: 才发现搞忘吧total time改成0了.. 目前是我测试时的total time.. <- fixed now.