c++ - Eclipse 格式化程序 : Enums and Constructor

标签 c++ eclipse

我尝试在 eclipse 中为我的代码格式化程序应用一些指导方针,但我有两个问题: 首先,枚举类:

我在格式化后的期望:

enum class Type : uint8_t 
{
    first = 1,
    second = 2,
    third = 3
}

格式化后得到的结果:

enum class Type
    : uint8_t {
        first = 1, 
    second = 2, 
    third = 3
}

第二件事是构造函数: 同样,我的期望是:

Example::Example(int x) :
    _x(x)
{
}

我得到的是:

Example::Example(int x) :
        _x(x)
{
}

所以我必须更改枚举的换行符和构造函数分配列表的缩进。但遗憾的是我没有找到这个选项.. 有人可以帮忙吗?

最佳答案

您可以使用 Project Properties->C/C++ General->Formatter 选项卡控制格式化选项:

enter image description here

使用 Edit 弹出以下包含所有选项的窗口:

enter image description here

关于 enum 声明,似乎只能控制换行选项:

enter image description here

关于c++ - Eclipse 格式化程序 : Enums and Constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29643425/

相关文章:

java - Eclipse 重构 - 仅限 Java

eclipse - 在Eclipse的XPath中无法使用变量-Selenium

c++ - OpenCV 透视校正和裁剪

C++ 编译 : what did i do wrong

c++ - 克服rpc字节顺序转换

java - 从 web.xml 文件获取初始化参数。在 Eclipse 和 Tomcat 中

eclipse - eclipse中的"open call hierarchy"无法正常工作

c++ - "static property"和静态常量值有什么区别?

c++ - exif和xmp有什么关系?它们可以互换吗?

c++ - 没有可用的源 "libstdc++-6!_ZNSo9_M_insertIlEERSoT_() at 0x6fc868a8"