How to use spell check with vim
Vim is a fantastic editor, with a lot of tricks up its sleeve. It makes a great
programmer's text editor, a great quick text file editor. There are times
when we edit prose in Vim, such as in a project README or git commit
message. In those cases, we can use Vim’s spell-checking to help us avoid
embarrassing mistakes.
Switching on spell-checking
We can switch on spell checking with this command
:set spell
We can also specify the language
:set spell spelllang=en_us
The default spelllang is en, which includes all regions of English. The
available regions for the English language are:
en - all regions
en_au - Australia
en_ca - Canada
en_gb - Great Britain
en_nz - New Zealand
en_us – USA
Once spell check is enabled VIM will instantly highlight your misspelled
words..
Create your own dictionary
Add words to your own dictionary using the Zg
You can undo the add with zug
Mark a word as incorrectly spelled using zw
Undoes the incorrect marking zuw
Find misspelled words
You can jump forwards or backwards through the buffer to the next flagged
work using
]s
[s
Once you've located a word, z= will bring up the list of suggested words,
pick the associated number and press return and the new word will be
substituted in for the old one.
Here is the Vim spellchecker offering suggestions for the word devicess.
If you are working on code, you may get tired of seeing all the highlighted
misspelled "words" (i.e. function or variable names), and you can disable
spellchecking by using:
:set nospell
Help
All of this and more can be found in the Vim help pages
:help spell
:help 'spell'
:help ]s
:help [s
:help z=
:help zg
:help zw
:help spelllang
:help spellfile
:help spellfile-cleanup
Ashutosh