use*_*575 3 emacs indentation auto-indent cc-mode emacs24
在Emacs 24.4中,默认缩进行为已更改 - 现在新行自动缩进.从发行说明:
*** `electric-indent-mode' is now enabled by default.
Typing RET reindents the current line and indents the new line.
`C-j' inserts a newline but does not indent. In some programming modes,
additional characters are electric (eg `{').
Run Code Online (Sandbox Code Playgroud)
我更喜欢旧的行为,所以我补充道
(electric-indent-mode 0)
Run Code Online (Sandbox Code Playgroud)
到我的.emacs档案.但是,这会禁用所有电子角色,这不是我想要的.
是否有任何方法可以禁用新行为,同时仍然有像'{'或':'这样的字符触发缩进?
要删除?\n的electric-indent-chars.您可以通过以下方式全局执
(setq electric-indent-chars (remq ?\n electric-indent-chars))
Run Code Online (Sandbox Code Playgroud)
或仅在特定模式下(例如C):
(add-hook 'c-mode-hook
(lambda ()
(setq-local electric-indent-chars (remq ?\n electric-indent-chars))))
Run Code Online (Sandbox Code Playgroud)