问题
In my Emacs, space
key can indent correctly 1 line. If I select several lines, and press space
key, the indenting does not work.
By following this link, I try C-M-\
or C-M-q
, but C-M
deletes directly the whole block selected.
Here is my .emacs, could anyone help?
回答1:
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)
回答2:
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
回答3:
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.
回答4:
None of the above method worked for me except Kev's- and that is too verbose for my slow fingers.
For me, I can highlight the region and press Alt-left arrow . Strangely, even though Alt registers as meta in emacs, Esc-left arrow doesn't work.
来源:https://stackoverflow.com/questions/11713743/indent-several-lines-in-emacs