Emacs缩进C ++类方法? [英] Emacs indent for C++ class method?
问题描述
目前:
class B
{
public:
B()
{
}
};
但是我想要:
class B
{
public:
B()
{
}
};
有没有人如何使用.emacs?
谢谢!
尝试设置 inline-open
0
。这应该放置一个大括号,在同一个缩进级别上打开一个类内嵌式方法。例如:
(c-set-offset'inline-open'0)
还可能有其他东西,很难说。 CC-Mode 文档有更多的选项及其描述,也可能对您有帮助。
以下是我可以感兴趣的基于Linux编码风格的C ++风格的示例:
(defun vlad-cc-style()
(c-set-stylelinux)
(c-set-offset 'innamespace'0)
(c-set-offset'inextern-lang'0)
(c-set-offset'inline-open'0)
(c-set-offset'标签'*)
(c-set-offset'case-label'*)
(c-set-offset'access-label'/)
(setq c-basic-offset 4 )
(setq tab-width 4)
(setq indent-tabs-mode nil)
)
(add-hook'c ++ - 模式挂钩'vlad -cc-style)
希望有帮助。祝你好运!
For some reason, my emacs indent the c++ class method wrong.
Current:
class B
{
public:
B()
{
}
};
But I want:
class B
{
public:
B()
{
}
};
Does anybody how to make it in .emacs?
Thanks!
Try setting inline-open
to '0
. That should place a brace that opens an in-class inline method on the same indent level. For example:
(c-set-offset 'inline-open '0)
There also might be something else, it is hard to say. CC-Mode document has more options and its description that might also be helpful to you.
Below is the example of my C++ style that is based on Linux coding style that might be of interest to you:
(defun vlad-cc-style()
(c-set-style "linux")
(c-set-offset 'innamespace '0)
(c-set-offset 'inextern-lang '0)
(c-set-offset 'inline-open '0)
(c-set-offset 'label '*)
(c-set-offset 'case-label '*)
(c-set-offset 'access-label '/)
(setq c-basic-offset 4)
(setq tab-width 4)
(setq indent-tabs-mode nil)
)
(add-hook 'c++-mode-hook 'vlad-cc-style)
Hope it helps. Good Luck!
这篇关于Emacs缩进C ++类方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!