Created
July 15, 2018 05:02
-
-
Save mattboehm/9eae110541d3a7e35b2aed7c550b042f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"A small script to measure typing speed | |
"Shows speed in bottom bar when you leave insert mode | |
"Run :messages to see all recent speeds | |
"This script was a hack thrown together in 10-15 minutes and has not been well tested yet. | |
function! s:insertEnterTypespeed() | |
let b:startTime = localtime() | |
endfunction | |
function! s:insertLeaveTypespeed() | |
let chars = strlen(@.) | |
if chars | |
let elapsedTime = localtime() - b:startTime | |
let words = len(split(@.)) | |
let wpm = words / (elapsedTime * 1.0) * 60 | |
let cpm = chars / (elapsedTime * 1.0) * 60 | |
echom printf("%i chars %i words %i seconds %0.2f chars/min %0.2f words/min", chars, words, elapsedTime, cpm, wpm) | |
endif | |
endfunction | |
augroup typespeed | |
autocmd! | |
autocmd InsertEnter * call s:insertEnterTypespeed() | |
autocmd InsertLeave * call s:insertLeaveTypespeed() | |
augroup end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment