Thomas W.
Thomas W.

Reputation: 2224

Spell check of comments in C++ code with emacs

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

Upvotes: 18

Views: 3223

Answers (4)

sligocki
sligocki

Reputation: 6387

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.

Upvotes: 9

kindahero
kindahero

Reputation: 5867

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.

Upvotes: 4

mirk
mirk

Reputation: 5530

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.

Upvotes: 12

Matthias
Matthias

Reputation: 8180

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

Upvotes: 1

Related Questions