C++ Code formatting for VS Code

Wanted to get our students using a standard code formatting :slight_smile: noticed that you can turn one on from here, C++ programming with Visual Studio Code

But that puts braces on new lines, which we didn’t like. It sounded like we should just be able to add a

.clang-format
file (put in under
.vscode
with maybe something like

BreakBeforeBraces: BS_Attach

per Clang-Format Style Options — Clang 19.0.0git documentation, but no joy. Anyone familiar with how to configure this?

It looks like you can use a .clang-format file, just follow these instructions and you should be set.

The .clang-format file needs to be in your workspace, not the .vscode settings directory within your workspace.

ahh, by “inside your workspace” I expected that it meant anywhere. Put at the root level of the workspace and it is finding it and working. I ended up using

BreakBeforeBraces: Attach
and that seemed to be what I wanted (for braces at least).

Thanks much auscompgeek!