Reputation: 35557
When creating conditional statements, or mthods, the IDE jumps to this:
if (true)
{
//code here
}
But I'd prefer the following more compact style (and often used in text books)
if (true) {
//code here
}
Is there a setting in visual studio to change the default style?
Upvotes: 5
Views: 4052
Reputation: 50114
Go Tools
> Options
in the top menu bar.
In the left panel, go to Text Editor
> C#
> Code Style
> Formatting
> New Lines
.
The option for if
blocks is Place open brace on new line for control blocks
, but you may want to change it for other types of block too. You may also want to change Place "else" on new line
.
Upvotes: 14
Reputation: 4695
Tools > Options > Text Editor > C# > New Lines > Place open brace on new line...
Upvotes: 3