Go to the first, previous, next, last section, table of contents.
There are two ways to customize the indentation style for the C-like modes. First, you can select one of several predefined styles, each of which specifies offsets for all the syntactic symbols. For more flexibility, you can customize the handling of individual syntactic symbols. See section Syntactic Symbols, for a list of all defined syntactic symbols.
c-set-offset
). The second argument offset specifies the
new indentation offset.
The c-offsets-alist
variable controls the amount of
indentation to give to each syntactic symbol. Its value is an
association list, and each element of the list has the form
(syntactic-symbol . offset)
. By changing the offsets
for various syntactic symbols, you can customize indentation in fine
detail. To change this alist, use c-set-offset
(see below).
Each offset value in c-offsets-alist
can be an integer, a
function or variable name, a list, or one of the following symbols: +
,
-
, ++
, --
, *
, or /
, indicating positive or negative
multiples of the variable c-basic-offset
. Thus, if you want to
change the levels of indentation to be 3 spaces instead of 2 spaces, set
c-basic-offset
to 3.
Using a function as the offset value provides the ultimate flexibility
in customizing indentation. The function is called with a single
argument containing the cons
of the syntactic symbol and
the buffer position, if any. The function should return an integer
offset.
If the offset value is a list, its elements are processed according
to the rules above until a non-nil
value is found. That value is
then added to the total indentation in the normal manner. The primary
use for this is to combine the results of several functions.
The command C-c C-o (c-set-offset
) is the easiest way to
set offsets, both interactively or in your `~/.emacs' file. First
specify the syntactic symbol, then the offset you want. See section Syntactic Symbols, for a list of valid syntactic symbols and their meanings.
Go to the first, previous, next, last section, table of contents.