Indent from point to under an indentation point in the previous line.
@end table
- Most programming languages have some indentation convention. For Lisp
-code, lines are indented according to their nesting in parentheses. The
-same general idea is used for C code, though many details are different.
+ Emacs supports four general categories of operations that could all
+be called `indentation':
+
+@enumerate
+@item
+Insert a tab character. You can type @kbd{C-q @key{TAB}} to do this.
+
+A tab character is displayed as a stretch of whitespace which extends
+to the next display tab stop position, and the default width of a tab
+stop is eight. @xref{Display Custom}, for more details.
+
+@item
+Advance to the next tab stop. You can set tab stops at your choice of
+column positions, then type @kbd{M-i} to advance to the next tab stop.
+The default is to have tab stops every eight columns, which means by
+default @kbd{M-i} inserts a tab character. To set the tab stops, use
+@kbd{M-x edit-tab-stops}.
+
+@item
+Align a line with the previous line. More precisely, the command
+@kbd{M-x indent-relative} indents the current line under the beginning
+of some word in the previous line. In Fundamental mode and in Text
+mode, @key{TAB} runs the command @code{indent-relative}.
+
+@item
+The most sophisticated method is @dfn{syntax-driven indentation}.
+Most programming languages have an indentation convention. For Lisp
+code, lines are indented according to their nesting in parentheses. C
+code uses the same general idea, but many details are different.
@kindex TAB
- Whatever the language, to indent a line, use the @key{TAB} command. Each
-major mode defines this command to perform the sort of indentation
-appropriate for the particular language. In Lisp mode, @key{TAB} aligns
-the line according to its depth in parentheses. No matter where in the
-line you are when you type @key{TAB}, it aligns the line as a whole. In C
-mode, @key{TAB} implements a subtle and sophisticated indentation style that
-knows about many aspects of C syntax.
-
- In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which
-indents to the next tab stop column. You can set the tab stops with
-@kbd{M-x edit-tab-stops}.
+Type @key{TAB} to do syntax-driven indentation, in a mode that
+supports it. It realigns the current line according with the syntax
+of the preceding lines. No matter where in the line you are when you
+type @key{TAB}, it aligns the line as a whole.
+@end enumerate
- Normally, @key{TAB} inserts an optimal mix of tabs and spaces for
-the intended indentation. @xref{Just Spaces}, for how to prevent use
-of tabs.
+ Normally, all of the above methods insert an optimal mix of tabs and
+spaces to align to the desired column. @xref{Just Spaces}, for how to
+disable use of tabs. However, @kbd{C-q @key{TAB}} always inserts a
+tab, even they are disabled for the indentation commands.
+
+@c In Text mode, @key{TAB} runs the command @code{tab-to-tab-stop}, which
+@c indents to the next tab stop column. You can set the tab stops with
+@c @kbd{M-x edit-tab-stops}.
@menu
* Indentation Commands:: Various commands and techniques for indentation.
but there is a default value which you can change as well.
@xref{Locals}.
+ A tab is not always displayed in the same way. By default, tabs are
+eight columns wide, but some people like to customize their tools to
+use a different tab width. So by using spaces only, you can make sure
+that your file looks the same regardless of the tab width setting.
+
@findex tabify
@findex untabify
There are also commands to convert tabs to spaces or vice versa, always
region for sequences of spaces, and converts sequences of at least three
spaces to tabs if that can be done without changing indentation. @kbd{M-x
untabify} changes all tabs in the region to appropriate numbers of spaces.
+
+@ignore
+ arch-tag: acc07de7-ae11-4ee8-a159-cb59c473f0fb
+@end ignore