Can't find a way to make formatters put braces on the same line. The default formatter seems to completely ignore all the settings related to new lines.
Some people recommended C# FixFormat extension, but now it's deprecated and gone from the marketplace. I also found
Then create a file named .editorconfig
in your project directory with the following content:
[*.cs]
csharp_new_line_before_open_brace = none
If the file already exists, modify or add the csharp_new_line_before_open_brace = none
line in the block for [*.cs]
files.
In order to not have linebreaks before else, catch and finally, also add these lines:
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_finally = false
If you want to apply the settings in all your projects, you can either
- place the
.editorconfig
file in a common parent directory of your project directories or - place the
.editorconfig
file in the home directory. In Windows, this is the directory under %HOMEPATH%.