hi experts/gurus:
I recently use vim to exercise my reading speed , and I use an external
stopwatch application to count in order to be accurately count my time
(in seconds).
while it works that way it's a pain to switch over between vim and that
stopwatch application over and over.
is it possible to have a small stopwatch displaying in the status line,
triggered/reset simply by a key hit?
I did some google search and didn't find anything good on this. I got
following code (leaforestd@gmail.com) somewhere but it doesn't work for
my desire:
function! Vtimer_enter()
let s:v_start = localtime()
endfunction
function! Vtimer_leave()
let s:v_end = localtime()
let s:v_add = s:v_end - s:v_start
let s:v_total = str2nr(readfile($HOME.'/.vim/vtimer/time')[0])
let s:v_total = s:v_total + s:v_add
call writefile([s:v_total], $HOME.'/.vim/vtimer/time')
endfunction
function! Vtimer_show()
let s:v_total = str2nr(readfile($HOME.'/.vim/vtimer/time')[0])
let s:v_h = s:v_total / 3600
let s:v_m = (s:v_total % 3600) / 60
let s:v_s = s:v_total % 60
echo s:v_h . 'h ' . s:v_m . 'm ' . s:v_s .'s'
endfunction
function! Vtimer_reset()
call writefile([0], $HOME.'/.vim/vtimer/time')
endfunction
autocmd VimEnter * call Vtimer_enter()
autocmd VimLeavePre * call Vtimer_leave()
command! Showtime call Vtimer_show()
command! Resettime call Vtimer_reset()
thanks!
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Sunday, May 20, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment