Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio switch statement formatting

I'm using Visual Studio 2005. It always wants to format switch statements like this:

switch (thing) { case A:   stuff;   break;  case B:   things;   break; } 

Is there a way to have it indent the cases like this?:

switch (thing) {   case A:     stuff;     break;    case B:     things;     break; } 
like image 439
Michael Warner Avatar asked Mar 04 '09 21:03

Michael Warner


People also ask

How to set Formatting in Visual Studio?

To access this options page, choose Tools > Options from the menu bar. In the Options dialog box, choose Text Editor > C# > Code Style > Formatting.

How do I fix format in Visual Studio?

As long as your code is syntactically correct (i.e. no stray brackets or End Ifs without matching Ifs), Visual Studio will reformat your whole file with one key chord: Hold down the Control key and then press K, followed by D. Boom! Everything looks pretty again.

How to auto format c# code in Visual Studio?

Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.


1 Answers

Go here:

Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels

like image 52
Andrew Hare Avatar answered Oct 08 '22 15:10

Andrew Hare