-
Notifications
You must be signed in to change notification settings - Fork 16
/
timer.vim
55 lines (44 loc) · 1.05 KB
/
timer.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
set statusline=Time:\ \ %{ClockDiff()}\ sec.\ Chars:\ %{Chars()}\ CPM:\ %{CalcCPM()}
function! ClockInit()
let s:clock = (strftime("%I") * 3600) + (strftime("%M") * 60) + (strftime("%S"))
endfunction
function! ClockDiff()
let l:now = (strftime("%I") * 3600) + (strftime("%M") * 60) + (strftime("%S"))
return (l:now - s:clock)
endfunction
function! StartRecording()
exe "normal qY"
endfunction
function! StopRecording()
exe "normal q"
endfunction
function! ClearRecording()
let @y = ""
endfunction
function! Chars()
let l:len = strlen(@y)
return len
endfunction
function! CalcCPM()
call StopRecording()
let l:diff = ClockDiff()
if l:diff <= 0
call StartRecording()
return 0
else
call StartRecording()
let l:cpm = strlen(@y) * 60 / ClockDiff()
return l:cpm
endif
endfunction
" set updatetime=1000
" autocmd! CursorHold * call Timer()
" autocmd! CursorHoldI * call Timer()
function! Timer()
call feedkeys("f\e")
" let &ro=&ro
endfunction
call ClockInit()
call ClearRecording()
call StartRecording()
echo @y