make Clang-Format忽略换行符的注释

时间:2017-06-24 01:48:32

标签: c++ clang clang-format autoformatting

是否可以告诉Clang-Format忽略换行操作的注释?我的想法是遵循风格"代码格式正确,即使评论超过换行符#34;代码不应分成多行,如果它不超过保证金,但注释不会。

e.g。

//desired behaviour:
short code = shortCode + 
        longlonglongCode;
short code = shortCode; //long comment without a line break

//not desired behaviour:
short code =
    shortCode;  //long comment without a line break

1 个答案:

答案 0 :(得分:4)

  

ReflowComments(bool

     

如果trueclang-format将尝试重新发送评论。

false:
// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
/* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */

true:
// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
// information
/* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
 * information */

Source