Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using emacs as my text editor for c/c++ code. Is there any tool which spell check comments for me?

Thank you.

share|improve this question

2 Answers 2

Try <META-x> ispell-comments-and-strings. It does what it says.

share|improve this answer

flyspell does in-line spell checking and highlights incorrect words as you type. Just make sure you activate flyspell-prog-mode to spell-check only the comments (instead of flyspell-mode, which checks the whole text, and will get lost in your source code).

After you activate flyspell only newly typed text is spell-checked. You have to run flyspell-buffer to check existing text. I have the following in my initialization file to automatically do this:

(defun my/flyspell-buffer-after-activation ()
  "Run `flyspell-buffer' after `flyspell-mode' is activated."
  (when flyspell-mode
    (flyspell-buffer)))

(add-hook 'flyspell-mode-hook 'my/flyspell-buffer-after-activation)
share|improve this answer
    
Thanks. What if i have existing code, how can I spell check comments with flyspell? –  n179911 May 13 at 15:04
    
You have to run flyspell-buffer. See my edit on how to automate this. –  Francesco May 13 at 17:19

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.