Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Brace formatting with Resharper

I'm using Resharper 4.5 and I need custom formatting of braces when writing an array or object initializer. Resharper supports some styles:

Gnu Style:

int[] array = new int[]                     {                         1, 2, 3                     }   

but I need:

int[] array = new int[]  {       1, 2, 3   }   

Is there any way to customize this templates?

like image 935
Hadi Eskandari Avatar asked Apr 14 '09 12:04

Hadi Eskandari


1 Answers

You can customize ReSharper to do just that, you'll need to do the following (All in ReSharper -> Options -> C# -> Formatting Style):

  1. In Braces Layout, set Array and object initializer to At Next line (BSD Style).
  2. In Other, make sure that Continuous line indent multiplier is set to 1.
  3. In Other, make sure that Indent array, object and collection initializer block is unchecked.

You should get the style you want.

like image 112
Igal Tabachnik Avatar answered Oct 13 '22 04:10

Igal Tabachnik