Indent several lines in Emacs
[Warning: This approach might lead to errors as mentioned in one of the comments. Iniviting suggestions to fix it.]
Steps to do indentation interactively.
- Select the region to be indented.
- C-x TAB.
- Use arrows (← and →) to indent interactively.
- Press Esc three times when you are done with the required indentation.
Select multiply lines, then type C-u 8 C-x Tab, it will indent the region by 8
spaces.
C-u -4 C-x Tab will un-indent by 4
spaces
If you want Emacs to correctly indent multiple lines, then the command is C-META \
also known as C-M-\
. In other words, it's not Control - M
, but Control - Meta - Backslash
(Control + Alt + \ on most keyboards)