Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Previous: Basic Indent, Up: Program Indent


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


 
 
  Published under the terms of the GNU General Public License Design by Interspire