Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code custom indentation style

For whatever reason (I hate it, but it is what it is), my company's standard style is to have braces indented to the same level as the code they contain, like this:

public static string StringName
    {
    get
        {
        return "string value";
        }
    }

This is really easy to set up in Visual Studio (Options > Text Editor > C# (or whatever language) > Code Style > Formatting > Indentation > Indent open and close braces), but I'm unsure how to automate this style in Code. Except for languages like Python where indentation is standardized, this is true of all languages I work in.

How can I accomplish this in Visual Studio Code?

like image 936
Nathan Smith Avatar asked Mar 01 '26 05:03

Nathan Smith


1 Answers

If you want Whitesmiths style and you're using C# by Omnisharp:
If there is not already such a file, create it: omnisharp.json
- in the root of your project if you want the format just for the particular project or
- at <userdata>/.omnisharp to use it globally.
Inside it put:

{  
"FormattingOptions":  
  {  
  "IndentBraces": true,  
  }  
}

Here you can find the complete list of formatting options.

like image 149
mireazma Avatar answered Mar 03 '26 12:03

mireazma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!