How can I tell Vim's spell checker to ignore words which have a leading capital?
It's annoying that, for example, MyWidget
is flagged as a spelling error.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With