Otiel
Otiel

Reputation: 18743

Prevent Visual Studio to add break lines in switch-case statements

Is there a way to prevent Visual Studio (2010) "Format document" menu to format the switch-case statements as the following:

When I write my code like:

switch (value) {
    case "1": mode = Mode.One; break;
    case "2": mode = Mode.Two; break;
}

And then hit "Format document", Visual Studio adds break lines:

switch (value) {
    case "1":
        mode = Mode.One;
        break;
    case "2":
        mode = Mode.Two;
        break;
}

I have looked into the Formatting section of VS Options, but I can't find anything relevant.

Options>Formatting

(I do not have ReSharper installed)

Upvotes: 8

Views: 1542

Answers (1)

Otiel
Otiel

Reputation: 18743

Found the setting that caused this:

Options > Text Editor > C# > Formatting > Wrapping > Leave statements and member declarations on the same line must be checked.

Options dialog

Upvotes: 7

Related Questions