EWSoftware / VSSpellChecker

A Visual Studio spell checker editor extension that checks the spelling of comments, strings, and plain text as you type. Supports configuration and various languages.
Other
377 stars 65 forks source link

How to exclude commented-out code #221

Closed franzalex closed 3 years ago

franzalex commented 3 years ago

Usually, I comment out code using the double comment mark in C# (////). When I do this, variable names (which are often contractions) tend to be highlighted as misspelt words.

The extension failed, however, to ignore commented-out code using the following exclusion regular expression:

(\/){4}([^\/]*)

How do I achieve my intended purpose of ignoring code commented out using the double comment mark? Thanks.

EWSoftware commented 3 years ago

The comment delimiters are not included in the spell checked text so are not present for the expression to find. Go to the C# Options in the configuration and enable the option to ignore quadruple slash comments.

franzalex commented 3 years ago

Thanks for the response, @EWSoftware. Is there any chance that such an option exists for VB?

EWSoftware commented 3 years ago

In the editor, all other languages use a generic tagger that uses the code classifications from the editor so it doesn't support the same options. That's not to say it can't be done but would require creating custom taggers and option sets for each requested language.

It can be implemented fairly easily for the project/solution spell checker as it uses a configuration file to define how the text is classified and you can override existing definitions or add new ones. For example, you could clone the rules for the VBStyle classifier and add a rule to match '''' comments and classify them as undefined so that they are ignored for project/solution spell checking.