Correct spelling error you just typed

3 Points

Chris Penner Chris Penner

8 years ago

Basically if you realize you made a spelling error but you've already typed past it you can hit <c-s> to fix it and then keep on typing. Each successive press corrects backwards to another error.

" Hit <c-s> to quickly correct your last spelling error and continue on.
func! SpellCorrect()
    let s:last_spell = &l:spell
    set spell
    exe "normal! mz[s1z=`z"
    " Restore value of 'spell' setting to what it was.
    let &l:spell=s:last_spell
endfunc
inoremap <c-s> <esc>:call SpellCorrect()<cr>A
nnoremap <c-s> <esc>:call SpellCorrect()<cr>`z