I would recommend against automatically fixing every word that is marked wrong, for two reasons.
- First, you'll get a lot of false positives on things you meant to type, especially in more technical writing.
You certainly can (and perhaps should) add these two your dictionary so that they're recognized and suggested.
However, if you don't notice that they're autocorrected, they could slip through to a final version of a document—or worse, if you're writing code or a configuration file (e.g., changing
min would make the graph look totally wrong).
Comments can also become weird (e.g., I had "Label and nullary instruction" changed to "Label and nullify instruction," which changes the meaning (a) from a noun phrase to an imperative, and (b) to meaning something completely different.)
- Second, the autocorrect is pretty poor on short words.
In my experience, it tends to complete to the closest word, which, with, e.g., three-letter words, can be totally different from what you mean.
If you mean to type of but accidentally type fo, it will be corrected to few—not what you wanted!
Again, these can be hard to catch in cursory revisions.
With that in mind, I think your real goal is to be able to quickly recognize and fix typographical errors.
I use the following mappings to accomplish this:
" Go back to last misspelled word and pick first suggestion.
inoremap <C-L> <C-G>u<Esc>[s1z=`]a<C-G>u
" Select last misspelled word (typing will edit).
nnoremap <C-K> <Esc>[sve<C-G>
inoremap <C-K> <Esc>[sve<C-G>
snoremap <C-K> <Esc>b[sviw<C-G>
When I'm typing body text, any misspelled words will be underlined, per my highlighting settings.
If I see that the word is relatively long and it's a simple typo, then I can figure that
spell will probably fix it correctly, so I hit
<C-L> and just keep typing.
If it's a shorter word or I anticipate that it will get it wrong, I can press
<C-K> and adjust it myself.
spell unexpectedly corrects to the wrong thing, I've set an undo marker with
<C-G>u, so I can just
<Esc>ucW to change it manually
This makes for a very quick workflow most of the time.