You would find it by yourself if you called it indent
. Indeed, there are many interactive functions that start with indent
. We easily find them with M-x indent TAB
. But we can also find documentation with C-h ?
, so if we try with C-h d RET indent RET
to search in functions' documentation, or with M-x apropos RET foo RET
we would also find them.
The following are built in and work with different languages (just tried with elisp, python and javascript):
M-x indent-region
formats the selected region,
indent-sexp
formats the current expression
There is no global option to configure the indentation, we need to dive in each mode's options. There is often options like (setq html-tab-width 4)
.
edit: some hints: (setq tab-width 8)
, (setq c-set-style "K&R")
, (setq c-basic-offset 8)
and with emacs' built in c-mode or GNU Indent you can switch styles: https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Choosing-a-Style or https://www.gnu.org/software/indent/manual/indent.html#SEC4