3

At some point an update broke my vim's spell checking ability. This is always a good opportunity to review my .vimrc. I figured out that vim's spell checking abilities actually go far further then just checking a word against a dictionary. It can check for words it can't find, words that are wrongly capitalized, words that are rare (bonus question: What is an example of a rare word?) and words that are wrong for the region selected. I updated my .vimrc to:

" Toggle spell checking
map <leader>ss :setlocal spell! spelllang=en_us<cr>

" Colors for words that failed spell check
" Word not recognized
hi clear SpellBad
hi SpellBad cterm=underline ctermfg=blue
" Word not capitalized
hi clear SpellCap
hi SpellCap cterm=underline ctermfg=red
" Word is rare
hi clear SpellRare
hi SpellRare cterm=underline ctermfg=green
" Wrong spelling for selected region
hi clear SpellLocal
hi SpellLocal cterm=underline ctermfg=yellow

Works like a charm! I now write a sentence:

enter image description here

and am surprised to learn that muon is wrong for the selected region. The way I understand this, is that muon is correct in one English dialect. My question now is: How do I figure out in what dialect this word is considered as correct?

1

Try :spelldump. A buffer will open with a long listing of words. At the top is something like:

/regions=usaucagbnz

This defines a set of regions for the current language, 1=us, 2=au, 3=ca, 4=gb, 5=nz. Searching for muon, we see:

Munson's/245
Munster
Munster's
muon/245
muon's/245
muons/245
Muppet
Muppet's
mural

Words that have no / are considered acceptable in any region. Words that have / followed by numbers are acceptable in those numbered regions. So, vim thinks muon is correct in Australia, Great Britain, and New Zealand, and nowhere else.

Now, I don't think this is actually true; muon is a valid word in all regions; but vim had to source its dictionaries from somewhere so it is bound by the accuracy of those sources. Fortunately, vim offers the ability to customize the spell checker dictionaries. The most basic way is to put your cursor over muon and type zg in normal mode.

As for rare words, there is only one listed in the default English dictionary: the word vim, and only in regions 2 and 5- Australia and New Zealand. You can do :/\w\/? to look for them. However, I wasn't able to get vim to actually call it a rare word in any region, probably because the word Vim is also listed in regions 2,5 so vim calls it SpellCap instead of SpellRare.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.