I have this C code and I’m using Clang in Visual Studio Code to auto-format when I save the file. I would like to add line breaks after my statements as seen below. I have included both C examples of what I am trying to achieve plus my Clang formatting.
int function(UINT32 debounce_time, UINT8 debounce_count)
{
int i;
button.debounce_interval = debounce_time;
if(1)
{
dosomething();
}
for (i = 0; i < MAX_PIN_HISTORY; i += 2)
{
button.pin_history[i] = 0;
}
for (i = 1; i < MAX_PIN_HISTORY; i += 2)
{
button.pin_history[i] = 1;
}
return;
}
However, I want it to be formatted like this (line breaks in-between the statements)
int function(UINT32 debounce_time, UINT8 debounce_count)
{
int i;
button.debounce_interval = debounce_time;
if(1)
{
dosomething();
}
for (i = 0; i < MAX_PIN_HISTORY; i += 2)
{
button.pin_history[i] = 0;
}
for (i = 1; i < MAX_PIN_HISTORY; i += 2)
{
button.pin_history[i] = 1;
}
return;
}
How can I do that? Here is my Clang file.
# Format Style Options - Created with Clang Power Tools
---
AlignAfterOpenBracket: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AlwaysBreakBeforeMultilineStrings: false
AttributeMacros:
- __capability
BasedOnStyle: Google
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakStringLiterals: false
ColumnLimit: 150
ContinuationIndentWidth: 2
IncludeBlocks: Preserve
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 8
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceInEmptyBlock: true
SpacesBeforeTrailingComments: 1
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
UseTab: ForIndentation
...
Thanks.