CW Holeman II
CW Holeman II

Reputation: 4971

Format Curly Braces on End Previous Line in C++ VSCode

Currently, I have the setting "C_Cpp.clang_format_formatOnSave" set to true.

This format's my code when I save my C++ file. But the format results in curly braces on new lines rather than on the same line.

Current C++ VSCode Formatted

for (int i = 0; i < 10; i++)
{
    // ...
}

What I Want C++ VSCode Formatted Code to Look Like

for (int i = 0; i < 10; i++) {
    // ...  }

How can I make curly braces in C++ format on end of the previous line in Visual Studio Code?

Not the same question as Format Curly Braces on Same Line in C++ VSCode.

Upvotes: 0

Views: 427

Answers (1)

CW Holeman II
CW Holeman II

Reputation: 4971

There is an Artistic Style VSCode extension:

Name: Astyle
Id: chiehyu.vscode-astyle
Description: Format C/C++/Obj-C/C#/Java code with Astyle in VSCode
Version: 0.9.0
Publisher: Chieh Yu
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=chiehyu.vscode-astyle

which has Python/Lisp indenting format feature:

--style=lisp / --style=python / -A12

Astyle found from @mmj's comment to 'How to make clang-format keep closing braces on same line'.

Upvotes: 0

Related Questions