vim spell check: ignore capitalized words?

You can define a syntax element to ignore spell checking.

" Ignore CamelCase words when spell checking
fun! IgnoreCamelCaseSpell()
  syn match CamelCase /\<[A-Z][a-z]\+[A-Z].\{-}\>/ contains=@NoSpell transparent
  syn cluster Spell add=CamelCase
endfun
autocmd BufRead,BufNewFile * :call IgnoreCamelCaseSpell()

Note that the autocmd is necessary to make sure that the syntax rules are loaded after the syntax definitions for the file type have been loaded (as the syntax rules wipe out any existing syntax rules).

However I'll personally prefer to add them (with zg) as good, so I can check there is no typo rather than ignoring everything.

Tags:

Vim