Emacs C++ 函数声明的模式缩进
我公司的编码标准已经改变,函数声明
void foo( int a, float* b);
现在必须写成:
void
foo(int a,
float* b);
其中变量的类型和变量的名称都必须垂直对齐。
我正在使用 emacs 23.2 和 c++ 模式。
此模式排列每个变量类型,但不允许我缩进变量名称以匹配。
是否有内置设置允许这样做?
如果没有,我需要关闭什么才能允许我自由缩进变量名称?
The coding standards at my company have changed such that the function declaration
void foo( int a, float* b);
must now be written as:
void
foo(int a,
float* b);
Where both the type of the variable and the name of the variable must be vertically aligned.
I'm using emacs 23.2 with c++-mode.
This mode lines up each variable type but won't let me indent the variable names to match.
Is there a build in setting to allow this?
If there isn't, what do I need to turn off to allow me to freely indent my variable names?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您想要的是
Mi
(tab-to-tab-stop
)。这会将光标移动到下一个制表位。制表位可以通过变量
tab-stop-list
配置,默认为每八列一次。请注意,这将插入空格或实际制表符,具体取决于局部变量indent-tabs-mode
。 (注意不要将其与tab-width
混淆,后者会影响实际 TAB 字符的显示方式。)这并不总是使参数名称位于尽可能低的列中,例如,您最终可能会得到
但请注意,这在某种程度上更易于维护——当添加具有较长类型名称的新参数时,您不一定需要修复其余部分,只有在跨越选项卡列时才需要修复。
Perhaps what you want is
M-i
(tab-to-tab-stop
).This will move the cursor to the next tab stop. The tab stops may be configured by the variable
tab-stop-list
, which defaults to every eight columns. Note this will either insert spaces or actual TAB characters depending on the local variableindent-tabs-mode
. (Be careful to not confuse this withtab-width
, which influences how actual TAB characters are displayed.)This will not always make the param names in the lowest possible column, e.g., you may end up with
but note that this is somewhat more maintainable-- when adding a new param with a longer type name you won't necessarily have to go fix up the rest, you'll only have to if you cross a tab column.
选择带有参数的行,然后Mxalign
Select the lines with the arguments then M-x align