pickle323
pickle323

Reputation: 653

Vim: Trying to modify the spell checker to exclude "rare" words

As per the documentation in :help spell, Vim's in-built spell checker detects 4 types of misspellings: SpellBad, SpellCap, SpellRare, SpellLocal

I would like to keep SpellBad & SpellLocal but I want to disable SpellCap & SpellRare. Turning the highlighting off for them is easy enough. However when try to forward or backward to the next/previous misspelled word with ]s & [s, SpellCap & SpellRare words are included.

I have managed to disable SpellCap by putting set spellcapcheck= in my .vimrc, however I can't seem to find any way to do a similar thing for SpellRare.

Using [S & ]S instead of [s & ]s would be a good solution however this only moves you to next/previous SpellBad word. I want it to include SpellBad & SpellLocal words.

Does anyone now how to do this?

Upvotes: 5

Views: 1410

Answers (2)

pickle323
pickle323

Reputation: 653

OK, so for anyone who's interested, here's an exact instruction set of how I did this.

  1. Add set spellcapcheck= into your vimrc. This will disable the spellcheck on words that aren't capitalized after a fullstop. This is an optional step, make up your own mind if you want this or not.
  2. Download the complete English dictionary pack (that contains all the different versions of English) from Open Office's dictionary archive - here's the link http://archive.services.openoffice.org/pub/mirror/OpenOffice.org/contrib/dictionaries/en_EN-pack.zip
    Unzip it into a directory & then unzip all the resulting zip files into that same directory.
  3. Make sure your terminal is in the directory that you've just unzipped everything into & then open Vim or gVim. Then run the command :mkspell xxxxx en_AU en_CA en_GB en_NZ en_US (just replace xxxxx with whatever name you want to give your dictionary)
    You'll be prompted with numerous messages about duplicate entries. I recommend just holding the 'Enter' button down to make these go away as fast as possible.
    If everything worked you should end up with a file in your directory called xxxxx.utf-8.spl. Move that file over to ~/.vim/spell
  4. Put set spelllang=xxxxx_yy into your vimrc, where yy is the 2 letter lowercase abbreviation of your desired region (au, ca, gb, nz or us)
    From here on in, your spellchecker should only ever indicate misspelled words or words from another region & none of those annoying "rare" words.

NB Some of you may have noticed that when making my dictionary, I didn't include the hyphenation dictionaries (hyph_en_GB & hyph_en_US). This was b/c I when I tried to include them, the spl file didn't generate. Maybe someone else can shed some light on why this was the case &/or how to fix it.

Upvotes: 6

Ingo Karkat
Ingo Karkat

Reputation: 172600

You could override the ]s mappings to skip rare spell errors (e.g. by checking the syntax), but the cleanest approach would be building custom spellfiles that exclude the rare words.

As these are identified by the ? flag (:help spell-RARE), filtering them out should be trivial to do. Building them (:help Myspell) might be more complex; I haven't done that so far.

Upvotes: 1

Related Questions