格式化构造构件成员初始化,不稳定

Format constructor member initialization with Uncrustify

本文关键字:初始化 不稳定 成员 构件 格式化      更新时间:2023-10-16

我正在使用不稳定的0.56,我想知道是否可以格式化这样的构造函数:

MyClass::MyClass(int arg1, int arg2, int arg3) : m_arg1(arg1), m_arg2(arg2), m_arg3(arg3) {}
// shall be formatted to
MyClass::MyClass(int arg1, int arg2, int arg3) : 
   m_arg1(arg1), 
   m_arg2(arg2), 
   m_arg3(arg3)
{
}

我找不到任何选择。这可能是可能的还是其他代码美化/工具可以实现这种格式?

预先感谢...

Uncrustify 0.59

# Whether to indent the stuff after a leading class colon.
# The term "class colon" refers to both 'class Dog: public Animal'
#                                                 ^
# and 'Dog::Dog(): Animal(), _fur(BLACK)'.
#                ^
indent_class_colon = true
# Add or remove a newline around a class colon.
# Related to <pos_class_colon>, <nl_class_init_args>, and <pos_comma>.
nl_class_colon     = force
# Add or remove newline after each ',' in the constructor member initialization.
nl_class_init_args = force

当前,Uncrustify是我知道的最灵活和可配置的野兽。过去,我已经尝试了不同代码格式器的音调,包括非免费代码。但是,我发现它们要么缺少一些重要的选择或包含讨厌的错误,其中包括:Eclipse CDT,Astyle,Jindent等的内置代码格式。