Eclipse Formatter:枚举和构造函数

时间:2015-04-15 06:52:14

标签: 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)
{
}

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

1 个答案:

答案 0 :(得分:2)

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

enter image description here

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

enter image description here

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

enter image description here