Next: Tab Stops, Previous: Indentation, Up: Indentation
To move over the indentation on a line, do M-m
(back-to-indentation
). This command, given anywhere on a line,
positions point at the first nonblank character on the line, if any,
or else at the end of the line.
To insert an indented line before the current line, do C-a C-o <TAB>. To make an indented line after the current line, use C-e C-j.
If you just want to insert a tab character in the buffer, you can type C-q <TAB>.
C-M-o (split-line
) moves the text from point to the end of
the line vertically down, so that the current line becomes two lines.
C-M-o first moves point forward over any spaces and tabs. Then it
inserts after point a newline and enough indentation to reach the same
column point is on. Point remains before the inserted newline; in this
regard, C-M-o resembles C-o.
To join two lines cleanly, use the M-^
(delete-indentation
) command. It deletes the indentation at the
front of the current line, and the line boundary as well, replacing them
with a single space. As a special case (useful for Lisp code) the
single space is omitted if the characters to be joined are consecutive
open parentheses or closing parentheses, or if the junction follows
another newline. To delete just the indentation of a line, go to the
beginning of the line and use M-\
(delete-horizontal-space
), which deletes all spaces and tabs
around the cursor.
If you have a fill prefix, M-^ deletes the fill prefix if it appears after the newline that is deleted. See Fill Prefix.
There are also commands for changing the indentation of several lines
at once. They apply to all the lines that begin in the region.
C-M-\ (indent-region
) indents each line in the “usual”
way, as if you had typed <TAB> at the beginning of the line. A
numeric argument specifies the column to indent to, and each line is
shifted left or right so that its first nonblank character appears in
that column. C-x <TAB> (indent-rigidly
) moves all of
the lines in the region right by its argument (left, for negative
arguments). The whole group of lines moves rigidly sideways, which is
how the command gets its name.
If you want to remove all indentation from all of the line in the region, invoke C-x <TAB> with a large negative argument, such as -1000.
M-x indent-relative indents at point based on the previous line
(actually, the last nonempty line). It inserts whitespace at point, moving
point, until it is underneath the next indentation point in the previous line.
An indentation point is the end of a sequence of whitespace or the end of
the line. If point is farther right than any indentation point in the
previous line, indent-relative
runs tab-to-tab-stop
unless it is called with a numeric argument, in which case it does
nothing.
See Format Indentation, for another way of specifying the indentation for part of your text.