Control sequences
I often have occasion to write on the go, and I love the sense of flow that I get when just free-writing. I don’t even look at the screen! But sometimes I know I’ve mistyped something and want to go back and do it over. How do you do that without breaking your flow?
For my chosen mobile typing platform (termux + vim), I’ve found that it’s helpful to have some quick commands like “delete the last word I typed”, or even “delete the last sentence I typed”. Vim’s ^W will delete a word, at the cost of leaving home row; you can break out of insert mode and delete back a sentence with ^Od(, but this is not easy to type! How can we easily run common commands while mid-thought?
After a lot of experimentation, I’ve settled on overloading some digraphs as commands. These need to meet two requirements:
- They must be unused in the language you’re typing, so they aren’t triggered as you write.
- They need to be convenient to type.
As a Dvorak typist, cg and cb fit the bill:
" Delete a word
noremap! cg <c-w>
" Delete a sentence (in a new undo scope)
noremap! <silent> cb <c-g>u<c-o>d(<c-o>x
With these handy remappings, when I am in a free-write session and know that I’ve flubbed a word, or want to restart the current sentence, I don’t have to look up or break my flow at all!