GNU Info

Info Node: (emacs)Multi-line Indent

(emacs)Multi-line Indent


Next: Lisp Indent Prev: Basic Indent Up: Program Indent
Enter node , (file) or (file)node

Indenting Several Lines
-----------------------

   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.

`C-M-q'
     Reindent all the lines within one parenthetical
     grouping(`indent-sexp').

`C-M-\'
     Reindent all lines in the region (`indent-region').

`C-u <TAB>'
     Shift an entire parenthetical grouping rigidly sideways so that its
     first line is properly indented.

`M-x indent-code-rigidly'
     Shift all the lines in the region rigidly sideways, but do not
     alter lines that start inside comments and strings.

   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 (Note: Indentation
Commands).  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.


automatically generated by info2www version 1.2.2.9