-1

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

Thank you.

2 Answers 2

1

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)
2
  • Thanks. What if i have existing code, how can I spell check comments with flyspell?
    – n179911
    May 13, 2014 at 15:04
  • You have to run flyspell-buffer. See my edit on how to automate this. May 13, 2014 at 17:19
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .