Skip to content

Instantly share code, notes, and snippets.

View kipawaa's full-sized avatar

River McCubbin kipawaa

View GitHub Profile
@kipawaa
kipawaa / WPM.vim
Created September 26, 2025 22:03
Vim WPM
" Provides a WPM function that returns an estimate of the current typing speed.
" intended use is with the status bar: add this file to `.vim/plugin` and
" `set statusline += WPM: %{WPM()}` in your `.vimrc`.
" WARNING: due to possible initialization issues, the first reported values
" can be wildly inaccurate.
" uses a circular buffer of `num_samples` wordcounts and `num_samples` times
" to sample WPM over (approximately) `num_samples` seconds and update the
" output of the `WPM` function (approximately) every 1s.
" Auto lists: Automatically continue/end lists by adding markers if the
" previous line is a list item, or removing them when they are empty
function! s:auto_list()
" get previous line
let l:prev_line = getline(line(".") - 1)
" get the leading whitespace from the previous line
let l:whitespace = matchstr(l:prev_line, '\v^\s*')
" if previous line is a non-empty ordered list item