1 |
@c This is part of the Emacs manual. |
@c This is part of the Emacs manual. |
2 |
@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc. |
@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2004 Free Software Foundation, Inc. |
3 |
@c See file emacs.texi for copying conditions. |
@c See file emacs.texi for copying conditions. |
4 |
@node Indentation, Text, Major Modes, Top |
@node Indentation, Text, Major Modes, Top |
5 |
@chapter Indentation |
@chapter Indentation |
75 |
Normally, all of the above methods insert an optimal mix of tabs and |
Normally, all of the above methods insert an optimal mix of tabs and |
76 |
spaces to align to the desired column. @xref{Just Spaces}, for how to |
spaces to align to the desired column. @xref{Just Spaces}, for how to |
77 |
disable use of tabs. However, @kbd{C-q @key{TAB}} always inserts a |
disable use of tabs. However, @kbd{C-q @key{TAB}} always inserts a |
78 |
tab, even they are disabled for the indentation commands. |
tab, even when tabs are disabled for the indentation commands. |
79 |
|
|
80 |
@c In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which |
@c In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which |
81 |
@c indents to the next tab stop column. You can set the tab stops with |
@c indents to the next tab stop column. You can set the tab stops with |
95 |
@findex back-to-indentation |
@findex back-to-indentation |
96 |
To move over the indentation on a line, do @kbd{M-m} |
To move over the indentation on a line, do @kbd{M-m} |
97 |
(@code{back-to-indentation}). This command, given anywhere on a line, |
(@code{back-to-indentation}). This command, given anywhere on a line, |
98 |
positions point at the first nonblank character on the line. |
positions point at the first nonblank character on the line, if any, |
99 |
|
or else at the end of the line. |
100 |
|
|
101 |
To insert an indented line before the current line, do @kbd{C-a C-o |
To insert an indented line before the current line, do @kbd{C-a C-o |
102 |
@key{TAB}}. To make an indented line after the current line, use |
@key{TAB}}. To make an indented line after the current line, use |
135 |
@findex indent-region |
@findex indent-region |
136 |
@findex indent-rigidly |
@findex indent-rigidly |
137 |
There are also commands for changing the indentation of several lines |
There are also commands for changing the indentation of several lines |
138 |
at once. @kbd{C-M-\} (@code{indent-region}) applies to all the lines |
at once. They apply to all the lines that begin in the region. |
139 |
that begin in the region; it indents each line in the ``usual'' way, as |
@kbd{C-M-\} (@code{indent-region}) indents each line in the ``usual'' |
140 |
if you had typed @key{TAB} at the beginning of the line. A numeric |
way, as if you had typed @key{TAB} at the beginning of the line. A |
141 |
argument specifies the column to indent to, and each line is shifted |
numeric argument specifies the column to indent to, and each line is |
142 |
left or right so that its first nonblank character appears in that |
shifted left or right so that its first nonblank character appears in |
143 |
column. @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of the |
that column. @kbd{C-x @key{TAB}} (@code{indent-rigidly}) moves all of |
144 |
lines in the region right by its argument (left, for negative |
the lines in the region right by its argument (left, for negative |
145 |
arguments). The whole group of lines moves rigidly sideways, which is |
arguments). The whole group of lines moves rigidly sideways, which is |
146 |
how the command gets its name.@refill |
how the command gets its name.@refill |
147 |
|
|
153 |
@findex indent-relative |
@findex indent-relative |
154 |
@kbd{M-x indent-relative} indents at point based on the previous line |
@kbd{M-x indent-relative} indents at point based on the previous line |
155 |
(actually, the last nonempty line). It inserts whitespace at point, moving |
(actually, the last nonempty line). It inserts whitespace at point, moving |
156 |
point, until it is underneath an indentation point in the previous line. |
point, until it is underneath the next indentation point in the previous line. |
157 |
An indentation point is the end of a sequence of whitespace or the end of |
An indentation point is the end of a sequence of whitespace or the end of |
158 |
the line. If point is farther right than any indentation point in the |
the line. If point is farther right than any indentation point in the |
159 |
previous line, the whitespace before point is deleted and the first |
previous line, @code{indent-relative} runs @code{tab-to-tab-stop} |
|
indentation point then applicable is used. If no indentation point is |
|
|
applicable even then, @code{indent-relative} runs @code{tab-to-tab-stop} |
|
160 |
@ifinfo |
@ifinfo |
161 |
(@pxref{Tab Stops}), |
(@pxref{Tab Stops}), |
162 |
@end ifinfo |
@end ifinfo |
166 |
unless it is called with a numeric argument, in which case it does |
unless it is called with a numeric argument, in which case it does |
167 |
nothing. |
nothing. |
168 |
|
|
|
@code{indent-relative} is the definition of @key{TAB} in Indented Text |
|
|
mode. @xref{Text}. |
|
|
|
|
169 |
@xref{Format Indentation}, for another way of specifying the |
@xref{Format Indentation}, for another way of specifying the |
170 |
indentation for part of your text. |
indentation for part of your text. |
171 |
|
|
177 |
@cindex tables, indentation for |
@cindex tables, indentation for |
178 |
@kindex M-i |
@kindex M-i |
179 |
@findex tab-to-tab-stop |
@findex tab-to-tab-stop |
180 |
For typing in tables, you can use Text mode's definition of @key{TAB}, |
For typing in tables, you can use @kbd{M-i} (@code{tab-to-tab-stop}). |
181 |
@code{tab-to-tab-stop}. This command inserts indentation before point, |
This command inserts indentation before point, enough to reach the |
182 |
enough to reach the next tab stop column. If you are not in Text mode, |
next tab stop column. |
|
this command can be found on the key @kbd{M-i}. |
|
183 |
|
|
184 |
@findex edit-tab-stops |
@findex edit-tab-stops |
185 |
@findex edit-tab-stops-note-changes |
@findex edit-tab-stops-note-changes |
193 |
edit-tab-stops}, which creates and selects a buffer containing a |
edit-tab-stops}, which creates and selects a buffer containing a |
194 |
description of the tab stop settings. You can edit this buffer to |
description of the tab stop settings. You can edit this buffer to |
195 |
specify different tab stops, and then type @kbd{C-c C-c} to make those |
specify different tab stops, and then type @kbd{C-c C-c} to make those |
196 |
new tab stops take effect. @code{edit-tab-stops} records which buffer |
new tab stops take effect. The buffer uses Overwrite mode |
197 |
was current when you invoked it, and stores the tab stops back in that |
(@pxref{Minor Modes}). @code{edit-tab-stops} records which buffer was |
198 |
buffer; normally all buffers share the same tab stops and changing them |
current when you invoked it, and stores the tab stops back in that |
199 |
in one buffer affects all, but if you happen to make |
buffer; normally all buffers share the same tab stops and changing |
200 |
|
them in one buffer affects all, but if you happen to make |
201 |
@code{tab-stop-list} local in one buffer then @code{edit-tab-stops} in |
@code{tab-stop-list} local in one buffer then @code{edit-tab-stops} in |
202 |
that buffer will edit the local settings. |
that buffer will edit the local settings. |
203 |
|
|
238 |
@findex untabify |
@findex untabify |
239 |
There are also commands to convert tabs to spaces or vice versa, always |
There are also commands to convert tabs to spaces or vice versa, always |
240 |
preserving the columns of all nonblank text. @kbd{M-x tabify} scans the |
preserving the columns of all nonblank text. @kbd{M-x tabify} scans the |
241 |
region for sequences of spaces, and converts sequences of at least three |
region for sequences of spaces, and converts sequences of at least two |
242 |
spaces to tabs if that can be done without changing indentation. @kbd{M-x |
spaces to tabs if that can be done without changing indentation. @kbd{M-x |
243 |
untabify} changes all tabs in the region to appropriate numbers of spaces. |
untabify} changes all tabs in the region to appropriate numbers of spaces. |
244 |
|
|