Function: newline-and-indent
newline-and-indent is an interactive and byte-compiled function
defined in simple.el.gz.
Signature
(newline-and-indent &optional ARG)
Documentation
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 ARG, perform this action that many times.
Also see open-line (bound to C-o (open-line)) for a command that
just inserts a newline without doing any indentation.
Probably introduced at or before Emacs version 21.1.
Key Bindings
Aliases
asm-newline (obsolete since 27.1)
org-newline-and-indent
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun newline-and-indent (&optional arg)
"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 ARG, perform this action that many times.
Also see `open-line' (bound to \\[open-line]) for a command that
just inserts a newline without doing any indentation."
(interactive "*p")
(delete-horizontal-space t)
(unless arg
(setq arg 1))
(let ((electric-indent-mode nil))
(dotimes (_ arg)
(newline nil t)
(indent-according-to-mode))))