[英]How to make cases in switch statement to be indented in Emacs
如何使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
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.