4

if I type in:

if (id < 0) {

followed by Enter key, Resharper re-formats it into.

if (id < 0) 
{

}

How can I tell it to reformat it into below, e.g. keep the brace with the if statement?

if (id < 0) {

}

P.S. I know about this question, but it addresses forcing curly braces around a single line, not keeping the brace with the if statement.

AngryHacker
  • 59,598
  • 102
  • 325
  • 594

2 Answers2

5

Looking at the other question you linked, it's really close to this, but it might be the difference you are interested in. I don't know if you can set K&R for just 'if' statements (as opposed to everything under 'Other'), but you can definitely set K&R as the standard across the board.

Indentation style can be found in the Options window under:

Code Editing > [Language] > Formatting Style > Braces Layout

enter image description here

This is as of Resharper 2018.1.2

mkautzm
  • 1,086
  • 2
  • 18
  • 34
1

From the ReSharper menu, choose Options, then navigate to:

Code Editing --> C# --> Formatting Style --> Braces Layout.

From there you can choose either:

  • At end of line (K&R style)
  • At end of line (no space)

enter image description here

Rufus L
  • 36,127
  • 5
  • 30
  • 43