IAdapter IAdapter - 1 year ago 60
C# Question

How to make Visual Studio not put { on a new line?

If I have code like this


and I add


it is transformed into

if (true)

but I would like it to stay in format

if (true) {

Even if I copy code that has
like this, it is transformed into the longer version.

P.S. I understand that it's a C++ and C# standard to use the longer version, however I do come from a different standard, and it's easier for me to use the shorter version.

I bet there is some formatter option that can be turned off or changed.

Answer Source

Go to Tools->Options->Text Editor->C#->Formatting->New Lines

Here there are a lot of options. Remove the check on all options here to never put the open bracket on a new line.


The section New Line Options for expressions does not relate to placement of code in conjunction with brackets, so those you don't need to touch.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download