" see nv_colon() in normal.c and op_colon() in ops.c
" the first two have to happen before & is rewritten
s/1:\zs\.//g
s/\d\+:\zs\.,\.+\d\+//g
s/:\zs'<lt>,'>//g

" see nv_abbrev(), nv_optrans(), nv_record(), nv_replace() in normal.c
s/<Del>\zs\d*dl//g
s/x\zs\d*dl//g
s/X\zs\d*dh//g
s/D\zs\d*d\$//g
s/C\zs\d*c\$//g
s/s\zs\d*cl//g
s/S\zs\d*cc//g
s/Y\zs\d*yy//g
s/&\zs\d*:s<CR>//g
s;q:\zs:<t_ýT>;;g
s;q/\zs/<t_ýT>;;g
s;q?\zs?<t_ýT>;;g
s/r<Tab>\zs\d\+R\(<Tab><Esc>\)\+//g
s/r<CR>\zs<CR><Esc>//g

" <C-V><BS> shows up as <C-V>, not sure why
s/<C-V>/<C-V><BS>/g

" these use @" in the cmdline so they have to happen before @" is rewritten
s;:lvimgrep/\\V\\<lt><C-R><C-W>.\{-}\\>/g\*\*;<C-8>;g
s;:lvimgrep/\\V\\(<C-R><C-W>.\{-}\\)/g\*\*;g<C-8>;g
s;y:lvimgrep/\\V\\<lt><C-R>=.\{-}\\>/g\*\*;<C-8>;g
s;y:lvimgrep/\\V\\(<C-R>=.\{-}\\)/g\*\*;g<C-8>;g
s;y/\\V\\<lt><C-R>=.\{-}\\><CR>;*;g
s;y/\\V\\(<C-R>=.\{-}\\)<CR>;g*;g
s;y?\\V\\<lt><C-R>=.\{-}\\><CR>;#;g
s;y?\\V\\(<C-R>=.\{-}\\)<CR>;g#;g

" more ins_typebuf() and stuffReadbuff() and stuffcharReadbuff() things.
" can't clean up <C-R> because on the cmdline there won't be a <CursorHold>
s/@@\zs.\{-}\ze<CursorHold>//g
s/@[0-9a-z".*+]\zs.\{-}\ze<CursorHold>//g
s/@=.\{-}<CR>\zs.\{-}\ze<CursorHold>//g
s/@:\zs.\{-}\ze<CursorHold>//g
s/:norm.\{-}<CR>\zs.\{-}\ze<CursorHold>//g
s/\.\zs\d.\{-}\ze<CursorHold>//g
s/<PasteStart>\zs.\{-}\ze<CursorHold>//g

" undo some mappings
s/:<C-U><C-R>=.\{-}\ze<CursorHold>//g          " vim-unimpaired [Q ]Q ...
s/:<C-U>exe<Space>.\{-}\ze<CursorHold>//g      " vim-unimpaired [q ]q ...
s/:<C-U>call<Space>.\{-}\ze<CursorHold>//g     " vim-unimpaired [e ]e ...
s/:<C-U>set<Space>.\{-}\ze<CursorHold>//g      " vim-unimpaired yot yow ...
s/:<C-U>if<Space>.\{-}\ze<CursorHold>//g       " vim-repeat     .
s/:let<Space>g:repeat_tick.\{-}<CursorHold>//g " vim-repeat     u U <c-r>
s/:<C-U>execute<Space>.\{-}\ze<CursorHold>//g  " vim-gitgutter  [c ]c
s/:GitGutterPreviewHunk<CR>/\\hp/g             " vim-gitgutter  \hp
s/:GitGutterStageHunk<CR>/\\hs/g               " vim-gitgutter  \hs
s/:GitGutterUndoHunk<CR>/\\hu/g                " vim-gitgutter  \hu
s/<Cmd>i<C-G>u<Right><C-C>.\{-}""/<C-O>/g      " c_CTRL-O.vim   <c-o>
s/<C-R>=execute('redraw')\[-1\]<NL>//g         " c_CTRL-O.vim   <c-o>
" s/:w<CR>/<Tab>/g " hmmm...
" s/:q!<CR>/ZQ/g
s/[@fFtT]\@<!,//g|s/[@fFtT]\@<!:/,/g|s//:/g
s/g+/g=/g
s/a<Del><Esc>/<S-Del>/g
s/<Right><Del><Left>/<S-Del>/g
s/<C-R>=strftime('%F')<CR>.\{-}<CursorHold>/<C-R><C-D>/g
s/<C-R>=strftime('%T')<CR>.\{-}<CursorHold>/<C-R><C-T>/g

" save this, will be used to detect keys being held down
s/<CursorHold>//g

" replace |key-notation| with single bytes. they are Latin-1
s/<t_..>//g
s/<LeftMouse>/©/g
s/<LeftDrag>//g
s/<LeftRelease>//g
s/<RightMouse>/®/g
s/<RightDrag>//g
s/<RightRelease>//g
s/<ScrollWheelUp>/ô/g
s/<ScrollWheelDown>/õ/g
s/<ScrollWheelLeft>/ó/g
s/<ScrollWheelRight>/ò/g
s/<PasteStart>/¶/g
s/<PasteEnd>//g
s/<ScriptCmd>//g
s/<Cmd>//g
s/<Space>/ /g
s/<Up>/â/g
s/<Down>/ã/g
s/<Left>/á/g
s/<Right>/à/g
s/<Tab>/¬/g
s/<S-Tab>/§¬§/g
s/<Esc>/×/g
s/<Insert>/¥/g
s/<CR>/¢/g
s/<BS>/«/g
s/<Del>/»/g
s/<S-Del>/§»§/g
s/<NL>/£/g

" clean up so that each byte in the log file corresponds to a key event
%s/<C-\(.\)>/¤\1¤/g
%s/<lt>/</g
%s/[!"#$%&()*+:<>?@A-Z^_{|}~]/§\0§/g " keys that require shift.
%s/¤§\(.\)§¤/¤\1¤/g " but shifted keys within ¤ don't actually require shift.
%s/¤¤//g " delete  ctrl-up followed by  ctrl-down. assume I hold it down.
%s/§§//g " delete shift-up followed by shift-down. assume I hold it down.
%s/§\([«¢× »]\+\)§/\1/g " these still work when shifted. assume I hold shift.
%s/\(.\)\1\1\+/\1·/g " replace sequences of 3+ identical keys that have no
%s///g              " intervening CursorHold with a · to mean 'held down'.
%s/¤¤//g " may have generated new occurrences of these. delete them.
%s/§§//g
%s/§\([«¢× »]\+\)§/\1/g
