Emacs switch 语句后的break缩进
现在,标准 emacs 缩进的工作方式如下:
switch (cond) {
case 0: {
command;
}
break;
}
我想要中断; 与案例对齐。
另外,是否有 c-set-offset 命令列表?
Right now the standard emacs indentation works like the following:
switch (cond) {
case 0: {
command;
}
break;
}
I want the break; to line up with case.
Also, is there a list of the c-set-offset commands somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(我发现)自定义缩进的最大帮助是弄清楚 cc-mode 使用什么来缩进当前行。 这就是 Cc Co 又名 Mx c-set-offset 可以做的 - 它允许您自定义语法元素的偏移量,并显示使用了什么元素对于当前行!
以下是您可以自定义它的方法。 将光标移至
break;
行。此时,您的代码将缩进如下:
有关偏移量的文档,请查看变量
'c-offsets-alist
的文档字符串类似地,您可以将其添加到 .emacs 中
:自定义缩进位于此处,值得一读。 有很多方法可以做到这一点,因此阅读手册是值得的(如果您想要非默认缩进)。 这是指向所有语法符号的指针用于 CC 模式。
The biggest help (I've found) in customizing indentation is figuring out what cc-mode uses to indent the current line. That's what C-c C-o aka M-x c-set-offset can do - it'll allow you to customize the offset for a syntactic element, and it shows you what element was used for the current line!
Here's how you can customize it. Move your cursor to the
break;
line.At which point, your code will be indented like:
For documentation on the offsets, check out the docstring for the variable
'c-offsets-alist
Similarly, you can add this to your .emacs:
The documentation for customizing indention is here and is worth reading. There are tons of ways to do it, so reading the manual is worth the time (if you want non-default indentation). And here's a pointer to all the syntactic symbols used in cc-mode.
对我来说,让 php-mode switch 语句正确缩进需要:
但正如其他人提到的,Cc Co 是你的朋友......
For me, getting php-mode switch statements to indent correctly requires:
But as others have mentioned, C-c C-o is your friend.....