Kevin Cox
Kevin Cox

Reputation: 3233

Spellcheck Entire File in Vim

I am currently using Vim's spell checking and it is great, however when pounding out a long letter or some notes I often find it easier to ignore spelling errors and come back later. However, mashing [z and then changing the word is a little annoying. I was wondering if there is some sort of wizard approach that could be used (like aspell check) that would go through all the misspelled words in the document and provide the option to fix/add/ignore them.

Upvotes: 4

Views: 1538

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172768

My SpellCheck plugin shows all spelling errors as a quickfix list via :SpellCheck. You can then use the built-in quickfix navigation (e.g. :cnext, maybe bound to a key mapping) to quickly go through the list. Commands like zg, z= etc. are forwarded to the target spell error.

Upvotes: 5

FvD
FvD

Reputation: 3794

One way is to map the spelling check key mappings to your numpad. It allows you to spell check the document quickly.

The keys I most often use are probably:

  • next misspelled word -> numpad 3
  • show alternatives ->numpad 5
  • choose alternative -> 5 (and then enter number of selection to change the word)
  • include the word in the dictionary -> numpad 8

It looks like this in my vimrc:

"------------------------------------
" Spell Check Key bindings
"------------------------------------  
nmap <silent> <F7> :call ToggleSpell()<CR>
nmap <k5> z=
nmap <k1> [s
nmap <k3> ]s
nmap <k8> zg
nmap <k9> zug

I'm used to it, and it is pretty fast, as you have all the spell-checking commands under one hand. And ToggleSpell allows me to turn on the spell check after I'm done with the draft, and choose the language I need for the final edit.

Upvotes: 3

Related Questions