How to exclude capitalized words from spell checking in Vim?

spell-checking, vim

Solution

Here is the solution that worked for me. This passes the cases I mentioned in the question:

syn match myExCapitalWords +\<\w*[A-Z]\K*\>+ contains=@NoSpell

Here is an alternative solution that uses `\S` instead of `\K`. The alternative solution excludes characters that are in the parenthesis and are preceded by a capitalized letter. Since it is more lenient, it works better for URLs:

syn match myExCapitalWords +\<\w*[A-Z]\S*\>+ contains=@NoSpell

Exclude "'s" from the spellcheck

`s` after an apostrophe is considered a misspelled letter regardless of the solution above. a quick solution is to add `s` to your dictionary or add a case for that:

syn match myExCapitalWords +\<\w*[A-Z]\K*\>\|'s+ contains=@NoSpell

This was not part the question, but this is a common case for spell checking process so I mentioned it here.

Problem

There are too many acronyms and proper nouns to add to the dictionary. I would like any words that contains a capital letter to be excluded from spell checking. Words are delimited by either a whilespace or special characters (i.e., non-alphabetic characters). Is this possible? The first part of the answer fails when the lowercase and special characters surround the capitalized word: ``` ,jQuery, , iPad, /demoMRdogood/ [CSS](css) `appendTo()`, ``` The current answer gives false positives (excludes from the spellcheck) when the lowercase words are delimited by a special character. Here are the examples: ``` (async) leetcode, eulerproject, ``` The bounty is for the person who fixes this problem.

Original source