Spell-checking is disabled by default. Enable spell-checking for the current buffer using:
:set spell
or, to enable spell-checking by default you can add this to your configuration:
vim.opt.spell = true
The default dictionary is defined as:
vim.opt.spelllang = "en"
Change the dictionary using an appropriate two-letter language code. For example "de" for German, "es" for Spanish, etc. Vim also supports regional dictionaries, such as "en_us", "en_ca", "en_gb", etc. Multiple dictionaries can be specified using a comma-separated list.
Navigating
Once spell-checking is enabled, Vim will highlight any misspelled words in the current buffer. You can quickly navigate the misspelled in the buffer using:
Command | Action |
---|---|
]s | move to next misspelled word |
[s | move to the previous misspelled word |
Correcting
With the cursor on a misspelled word, you can view a list of suggestions using z=. Type the number of the suggestion you would like to use and hit <CR> to replace the current word with the selected suggestion.
Alternatively, you can directly replace the word with a suggestion by specifying the number as a
count when calling z=. For example, 1z
will directly replace the current word with the first
suggestion in the list. This can be useful when you are confident that the first suggestion is
likely to be correct.
After correcting a word, you can repeat that correction for all occurrences in the current buffer using :spellrepall.
Adding / Removing Words
Vim's dictionaries are pretty good, but don't include jargon or other words that you may use in your writing. If a correct word is reported as incorrect, you can add it to the dictionary using one of the following commands:
Command | Action |
---|---|
zg | permanently mark word as correctly spelled |
zw | permanently mark word as incorrectly spelled |