Q. How do I re-indent the whole file?
A. Visit the file and hit C-x h to mark the whole buffer. Then hit ESC C-\.
Q. How do I re-indent the entire function? ESC C-x doesn't work.
A. ESC C-x is reserved for future Emacs use. To re-indent the entire function hit C-c C-q.
Q. How do I re-indent the current block?
A. First move to the brace which opens the block with ESC C-u, then re-indent that expression with ESC C-q.
Q. Why doesn't the RET key indent the line to where the new text should go after inserting the newline?
A. Emacs' convention is that RET just adds a newline, and that C-j adds a newline and indents it. You can make RET do this too by adding this to your
c-mode-common-hook
(see the sample `.emacs' file section Sample .emacs file):(define-key c-mode-base-map "\C-m" 'newline-and-indent)This is a very common question. If you want this to be the default behavior, don't lobby me, lobby RMS!
:-)
Q. I put
(c-set-offset 'substatement-open 0)
in my `.emacs' file but I get an error saying thatc-set-offset
's function definition is void.A. This means that @ccmode{} wasn't loaded into your Emacs session by the time the
c-set-offset
call was reached, mostly likely because @ccmode{} is being autoloaded. Instead of putting thec-set-offset
line in your top-level `.emacs' file, put it in yourc-mode-common-hook
, or simply add the following to the top of your `.emacs' file:(require 'cc-mode)See the sample `.emacs' file section Sample .emacs file for details.
Q. How do I make strings, comments, keywords, and other constructs appear in different colors, or in bold face, etc.?
A. "Syntax Colorization" is a standard Emacs feature, controlled by
font-lock-mode
. It is not part of @ccmode{}.
Go to the first, previous, next, last section, table of contents.