Search code examples
c#unity-game-engineformatjetbrains-iderider

How to edit the auto format in JetBrains Rider?


I'm frequently using auto format in Rider IDE but I don't like some of those formats. I already checked Editor > Code Style > C# and searched the internet but couldn't find the desired settings.

For example this what I want when auto format:

Desired format

But it changes like this when auto format which I don't want:

Unwanted format

Does anyone have an idea how to fix that?


Solution

  • For the attributes, you could alter the rule in Settings > Editor > Code Style > C# > Line Breaks and Wrapping > Arrangement of Attributes section > Place field attribute on the same line > Never


    For a more specific layout, what you're after is the File Layout, which is located in Settings > Editor > Code Style > C# > File Layout > General / Unity which will format your code based on patterns:

    Image of the File Layout in Rider

    There are several built-in patterns (Empty, Default, and Default with regions) but you can create your own.