[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When you wish to reindent several lines of code which have been altered or moved to a different level in the parenthesis structure, you have several commands available.
indent-sexp
).
indent-region
).
You can reindent the contents of a single parenthetical grouping by
positioning point before the beginning of it and typing C-M-q
(indent-sexp
in Lisp mode, c-indent-exp
in C mode; also
bound to other suitable commands in other modes). The indentation of
the line where the grouping starts is not changed; therefore, this
changes only the relative indentation within the grouping, not its
overall indentation. To correct that as well, type TAB first.
Another way to specify the range to be reindented is with the
region. The command C-M-\ (indent-region
) applies
TAB to every line whose first character is between point and
mark.
If you like the relative indentation within a grouping, but not the indentation of its first line, you can type C-u TAB to reindent the whole grouping as a rigid unit. (This works in Lisp modes and C and related modes.) TAB with a numeric argument reindents the current line as usual, then reindents by the same amount all the lines in the parenthetical grouping starting on the current line. It is clever, though, and does not alter lines that start inside strings, or C preprocessor lines when in C mode.
You can also perform this operation on the region, using the command
M-x indent-code-rigidly. It rigidly shifts all the lines in the
region sideways, like indent-rigidly
does (see section S.1 Indentation Commands and Techniques). It doesn't alter the indentation of lines that start
inside a comment or a string, unless the region starts inside that
comment or string.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |