Next: , Up: Electric Indent Mode   [Index]


8.10.1.1 Indenting New Lines

When you press ‘RET’ Emacs will insert a newline character and then invoke the major mode’s indentation engine. For this to work, you have to enable the minor mode electric-indent-mode.

newline-and-indent

Insert a NEWLINE, then indent according to major mode. Indentation is done using the value of ‘indent-line-function’. In programming language modes, this is the same as ‘TAB’. In some text modes, where ‘TAB’ inserts a tab, this command indents to the column specified by the function ‘current-left-margin’.

With electric indent, Emacs now also checks if you type certain block characters — like Python’s ‘:’ or ‘{’ and ‘}’ in C — and automatically re-indents the current line.