[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

31.3.2 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-pp-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-pp-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. Neither does it alter C preprocessor lines when in C mode, but it does reindent any continuation lines that may be attached to them.

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 (voir la section Indentation Commands and Techniques). It doesn't alter the indentation of lines that start inside a string, unless the region also starts inside that string. The prefix arg specifies the number of columns to indent.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.