How to make Emacs to indent cases like this
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
instead of
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
You need to add something like this to your .emacs (either as a general setting or for the specific programming modes you care about):
;; set this in all c-based programming modes
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-offset 'case-label '+)))
to add this to another mode, use the same pattern above with the relevant mode name substituted in for the hook, eg: <mode-name>-hook
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.