My usual Vim work flow is:
In insert mode, spell something wrong.
Press ^X s
to get some suggestions.
Press Esc to accept the first one.
After this, I'm in command mode in the middle of the line, instead of insert mode of where I was before. I could use A
, but that only works if I was typing on the end of the line. Is there an alternative way? Optimally, I'd like a command that corrects the last mistake to the first suggestion without moving the cursor.
Using Spellchecking To move to a misspelled word, use ]s and [s . The ]s command will move the cursor to the next misspelled word, the [s command will move the cursor back through the buffer to previous misspelled words. Just hit Enter if none of the suggestions work, or enter the number for the correct word.
From the Review tab, click the Spelling & Grammar command. The Spelling and Grammar pane will appear on the right. For each error in your document, Word will try to offer one or more suggestions. You can select a suggestion and click Change to correct the error.
An improvement to PDug's answer: To make the spelling correction undoable separately from the insertions, use this:
imap <c-l> <c-g>u<Esc>[s1z=`]a<c-g>u
<c-g>u
inserts an undo-break
The rest is the same.
This way, if you don't like the chosen correction, you can undo it using <Esc>u
. Without the undo-breaks, this would undo the complete insertion. Note that the undo-break at the end of the mapping ensures that text added after the correction can be undone separately from the correction itself.
Also, I found it convenient to map this to CTRL+F (which is easy to reach) in both insert and normal mode like this:
imap <c-f> <c-g>u<Esc>[s1z=`]a<c-g>u
nmap <c-f> [s1z=<c-o>
This way, you can quickly fix the last error (relative to the cursor).
This works fairly well:
imap ^L <Esc>[s1z=`]a
[s
moves to the last spelling mistake1z=
chooses the first suggestion`]
move to the last insert pointa
append text
I can't offer an 'optimal' solution (although I suspect there is a way).
However, you can use gi to enter insert mode at the place in the file where you last left it. (help gi
explains this more eloquently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With