Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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(){
        This is comment line in main function ..

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

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


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.