【问题标题】:Uncrustify: how do I set the indentation of the initializer list and function argumentsUncrustify:如何设置初始化列表和函数参数的缩进
【发布时间】:2017-09-29 17:16:30
【问题描述】:

我一直在尝试为构造函数获取缩进,如下所示:

ClassName::ClassName(const std::string &id,
                     std::shared_ptr<AbstractInterface> object,
                     bool isDynamic) :
    m_id(id),
    m_object(object),
    m_isDynamic(isDynamic),
    m_state(ClassState::CREATED)
{
}

我希望参数缩进,以便它们与参数列表的第一个括号对齐,但初始化列表应该缩进 4 个空格(这是我的常规缩进大小)。

我从包含此代码示例的代码示例文件生成了我的 uncrustify 配置。我已经看到我可以使用 indent_ctor_init,但是在生成的配置中设置为 0。

这是我应该用于初始化列表的配置选项吗?

我也无法找到为参数设置缩进的位置,因此在第一个参数之前没有换行符。

这就是我现在得到的:

ClassName::ClassName(
    const std::string &id,
    std::shared_ptr<AbstractInterface> object,
    bool isDynamic) :
    m_id(id),
    m_object(object),
    m_isDynamic(isDynamic),
    m_state(ClassState::CREATED)
 {
 }

【问题讨论】:

    标签: c++ code-formatting uncrustify


    【解决方案1】:

    我设法找到了解决方案。不确定哪些选项不正确。我找到了另一个配置文件,然后更改了indent_continue 选项和nl_func_decl_start(可能还有一个我已经忘记了),现在它看起来像我想要的那样。

    【讨论】:

      【解决方案2】:

      对于 uncrustify 0.71.0 我可以使用它

      indent_continue                 = 4
      nl_constr_colon                 = force
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-19
        • 2014-01-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-19
        相关资源
        最近更新 更多