首页 > 解决方案 > 阻止铿锵格式断线

问题描述

我想改变下面的行为(左边是它应该的样子,右边是它的结果)

示例1

示例图像

这是我目前的.clang-format


---
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignTrailingComments: 'true'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'true'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBraces: Allman
IndentWidth: '4'
SpaceAfterCStyleCast: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
Standard: Latest
TabWidth: '0'
UseTab: Never
PointerAlignment: Left
ColumnLimit: 0


...

它正确地将函数定义和参数放在同一行,但对于函数调用和 for 循环,例如,它并没有做同样的事情。

标签: c++clangclang-format

解决方案


推荐阅读