Search code examples
rider

How to format C# "else" onto one line in Rider


How can I get else to be on one line as it should be? (meaning } else { instead of the version shown below).

I am already using K&R style which fixes all other uses of braces (as shown below), but it does not fix the else.

Bad Format


Solution

  • There is a toggle in the "Editor" > "Code Style" > "C#" settings under the "Line Breaks and Wrapping" tab called "Place 'else' on new line": enter image description here

    Disabling this will achieve what you want.