Skip to content

Instantly share code, notes, and snippets.

@mattboehm
Created July 15, 2018 05:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattboehm/9eae110541d3a7e35b2aed7c550b042f to your computer and use it in GitHub Desktop.
Save mattboehm/9eae110541d3a7e35b2aed7c550b042f to your computer and use it in GitHub Desktop.
"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