This chapter will briefly cover how CC Mode indents lines of code. It is helpful to understand the indentation model being used so that you will know how to customize CC Mode for your personal coding style. All the details are in Customizing Indentation.
CC Mode has an indentation engine that provides a flexible and general mechanism for customizing indentation. When CC Mode indents a line of code, it separates its calculations into two steps:
+, which means “indent this line one more level” is a typical offset. CC Mode then applies these offset(s) to the anchor position, giving the indentation for the line. The different sorts of offsets are described in c-offsets-alist.
In exceptional circumstances, the syntax directed indentation
described here may be a nuisance rather than a help. You can disable
it by setting
nil. (To set
the variable interactively, Minor Modes).
When this is non-
nil (which it is by default), the indentation
of code is done according to its syntactic structure. When it’s
nil, every line is just indented to the same level as the
previous one, and TAB (
c-indent-command) adjusts the
indentation in steps of
c-basic-offset. The current style
(see Config Basics) then has no effect on indentation, nor do any
of the variables associated with indentation, not even
|• Syntactic Analysis|
|• Syntactic Symbols|
|• Indentation Calculation|