Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim spell check: ignore capitalized words?

Tags:

vim

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.

like image 949
David Wolever Avatar asked Sep 26 '11 21:09

David Wolever


1 Answers

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.

like image 94
mb14 Avatar answered Nov 05 '22 04:11

mb14