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; }
To access this options page, choose Tools > Options from the menu bar. In the Options dialog box, choose Text Editor > C# > Code Style > Formatting.
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.
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.
Go here:
Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With