AngryHacker
AngryHacker

Reputation: 61646

How can I force Resharper to place the curly brace on the same line?

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.

Upvotes: 6

Views: 3606

Answers (2)

mkautzm
mkautzm

Reputation: 1146

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

Upvotes: 6

Rufus L
Rufus L

Reputation: 37070

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

Upvotes: 1

Related Questions