2016-07-12 26 views
0

我遇到了麻烦uncrustify格式化C++ lambda表达式Uncrustify + LAMBDA

这是它令我的λ为:

auto print = [](auto const &i, qi::unused_type, qi::unused_type) 
      { 
       qDebug() << i; 
      }; 

这是我想什么:

auto print = [](auto const &i, qi::unused_type, qi::unused_type) 
{ 
    qDebug() << i; 
}; 

Doe现在什么设置都是负责大括号的定位?在您的配置文件

+0

你介意分享你的Uncrustify配置文件吗? – Quirk

+0

这里你去[链接](http://pastebin.com/dGcfMEaJ) –

回答

2

看,似乎有几个流氓设置:

  1. 在路223

    # Align continued statements at the '='. Default=True 
    # If FALSE or the '=' is followed by a newline, the next line is indent one tab. 
    indent_align_assign      = true  # false/true 
    

    正如你所看到的,你分配一个拉姆达的象征。其他换行符被配置为与作业的=符号对齐。

  2. 在线路830和833

    # The span for aligning on '=' in assignments (0=don't align) 
    align_assign_span       = 1  # number 
    
    # The threshold for aligning on '=' in assignments (0=no limit) 
    align_assign_thresh      = 0  # number 
    

    如果你不喜欢在路223改变配置,也许你可以尝试用这副设置玩耍。

如果更改任何这些设置对您而言并非真正合理,您可能需要进行一些严肃的代码风格改革。首先,我看到示例lambda适合作为一行语句。也许让他们保持单行。 (他们将保持这种方式,因为964行在你的配置文件确保)。

+0

感谢您仔细阅读它。 830/833没有帮助,因为跨越几行(在当前状态)跨越多行,所以跨度将需要像6,这将与其他人发生冲突。到目前为止,223编辑似乎做我想要的。我现在就去做这件事。我不想让这些羔羊作为参数列表很大的一行 –