如何使Emacs缩进这样的案例
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
代替
switch ($foo) {
case "foo":
$foo .= " bar";
break
case "bar":
$foo .= " baz";
break
default:
$foo .= " undefined";
}
你需要在.emacs中添加这样的东西(作为一般设置或你关心的特定编程模式):
;; set this in all c-based programming modes
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-offset 'case-label '+)))
要将此添加到另一个模式,请使用上面相同的模式,并在钩子中替换相关的模式名称,例如: <mode-name>-hook
。
你需要在.emacs中添加这样的东西(作为一般设置或你关心的特定编程模式):
;; set this in all c-based programming modes
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-offset 'case-label '+)))
要将此添加到另一个模式,请使用上面相同的模式,并在钩子中替换相关的模式名称,例如: <mode-name>-hook
。