Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm a C/C++ professional programmer who makes lots of spelling mistakes in comments. I want to configure vim such that the spell-checker only looks for misspelled words within comments. If necessary I'm willing to add special symbols around the comment that vim can look for to know where to check, such as:

 int main(){
     /*<--C_S 
        This is comment line in main function ..
        C_S-->*/
 }

If the plugin can work without the C_S symbols that'd be even better. I want the spell-checker to highlight any spelling mistakes it finds within comments. Does this already exist? Or is it easy to write myself?

share|improve this question

2 Answers 2

Good news, this is already part of Vim. Turn on syntax highlighting (:syntax enable) and this should be taken care of automatically with the default syntax files packaged with any reasonably recent vim distribution. See :help spell-syntax for an explanation. The short version is that syntax files can use @Spell and @NoSpell to specify where spell checking should or should not occur.

share|improve this answer

It already exists. Just type :set spell spelllang=en_us and it underlines spelling mistakes. Adjust the language to your needs. Additional languages can be found here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.