Search code examples
vimspell-checking

How do I correct Vim spelling mistakes quicker?


My usual Vim work flow is:

  • In insert mode, spell something wrong.

    Vim spell

  • Press ^X s to get some suggestions.

    Vim screen

  • 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.


Solution

  • This works fairly well:

    imap ^L <Esc>[s1z=`]a
    

    [s moves to the last spelling mistake
    1z= chooses the first suggestion
    `] move to the last insert point
    a append text