17

Is there a way to make a spell check of comments in C++ codes using emacs?

Thomas W.
  • 2,134
  • 2
  • 24
  • 46

4 Answers4

12

The lisp-snippet below in .emacs got it to work for me on Ubuntu Linux

(add-hook 'c-mode-common-hook 'flyspell-prog-mode)

There exist alternative setups. But I think you can find them by googling flyspell-prog-mode.

N.N.
  • 8,336
  • 12
  • 54
  • 94
mirk
  • 5,302
  • 3
  • 32
  • 49
9

To spell check comments already in the file:

M-x ispell-comments-and-strings

To spell check comments as you type:

M-x flyspell-prog-mode

and the .emacs hooks kindahero suggested.

sligocki
  • 6,246
  • 5
  • 38
  • 47
4

as mirk said flyspell-prog-mode is the obvious way.

To share my config,

;;; for prog modes turn on flyspell-prog-mode (checks spell only in comments)
(dolist (hook '(lisp-mode-hook
                emacs-lisp-mode-hook
                ruby-mode-hook
                yaml-mode
                python-mode-hook
                shell-mode-hook
                php-mode-hook
                css-mode-hook
                nxml-mode-hook
                crontab-mode-hook
                perl-mode-hook
                javascript-mode-hook
                LaTeX-mode-hook))
  (add-hook hook 'flyspell-prog-mode))

Remove those modes you don't use/want.

kindahero
  • 5,817
  • 3
  • 25
  • 32
1

Edit -> Spelling -> Ispell -> Spell-Check Comments

Matthias
  • 8,018
  • 2
  • 27
  • 53