25.1 Indentation Commands

Apart from the TAB (indent-for-tab-command) command, Emacs provides a variety of commands to perform indentation in other ways.


Split the current line at point (split-line). The text on the line after point becomes a new line, indented to the same column where point is located. This command first moves point forward over any spaces and tabs. Afterward, point is positioned before the inserted newline.


Move (forward or back) to the first non-whitespace character on the current line (back-to-indentation). If there are no non-whitespace characters on the line, move to the end of the line.


Indent whitespace at point, up to the next tab stop (tab-to-tab-stop). See Tab Stops.

M-x indent-relative

Insert whitespace at point, until point is aligned with the first non-whitespace character on the previous line (actually, the last non-blank line). If point is already farther right than that, run tab-to-tab-stop instead—unless called with a numeric argument, in which case do nothing.


Merge the previous and the current line (delete-indentation). This joins the two lines cleanly, by replacing any indentation at the front of the current line, together with the line boundary, 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 opening and closing parentheses, or if the junction follows another newline.

If there is a fill prefix, M-^ deletes the fill prefix if it appears after the newline that is deleted. See The Fill Prefix.

With a prefix argument, join the current line to the following line. If the region is active, and no prefix argument is given, join all lines in the region instead.


Indent all the lines in the region, as though you had typed TAB at the beginning of each line (indent-region).

If a numeric argument is supplied, indent every line in the region to that column number.


Indent all lines that begin in the region, moving the affected lines as a rigid unit (indent-rigidly).

If called with no argument, this command activates a transient mode for adjusting the indentation of the affected lines interactively. While this transient mode is active, typing LEFT or RIGHT indents leftward and rightward, respectively, by one space. You can also type S-LEFT or S-RIGHT to indent leftward or rightward to the next tab stop (see Tab Stops). Typing any other key disables the transient mode, and this key is then acted upon as normally.

If called with a prefix argument n, this command indents the lines forward by n spaces (without enabling the transient mode). Negative values of n indent backward, so you can remove all indentation from the lines in the region using a large negative argument, like this:

C-u -999 C-x TAB