I have the following line in my C++ code:
std::cout << "done" << "\n";
which clang-format breaks into
std::cout << "done"
<< "\n";
no matter what. I have edited every option that starts with "Break" or "Align":
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: None
AlignConsecutiveMacros: 'false'
AlignConsecutiveAssignments: 'false'
AlignConsecutiveBitFields: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: 'false'
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: false
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: AfterComma
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
How can I make it not do this? Version is 14.0.0
clang-format erroneously always puts consecutive << "string"
onto separate lines. This is a known bug, first reported in Feb 2020.
Your configuration works for for statements like:
// This doesn't get split over multiple lines;
// it only happens if the column limit is exceeded.
int x = 1 << 2 << 3;
Normally, only if a line is too long:
However, when a <<
is followed by a string literal, clang-format will put it onto a separate line, no matter what.