Formatting issue in Rider

已回答

Hey everyone. I've recently installed Rider to properly learn C# and since I already use pretty much only Jetbrains products for everything else, I went with Rider instead of Visual Studio for this.

However, I'm having an issue that I can't figure out. Thing is, I am very used to putting my opening braces on the same line as classes, functions, etc. I am aware that the default for C# is putting them in a new line but, still, I'd like to keep my standard.

I've configured the formater in Editor → Code Style → C# → Braces Layout to use K&R style and even created a .editorconfig and, in fact, it formats correctly, however, whenever I press Enter between 2 braces it briefly but the opening brace in a new line and only then puts it on the correct place. 

I know that, in theory, it works, but this is somewhat annoying and it really seems something's fighting against some other thing and doesn't feel right at all. Does anyone know what could be the source of this and how can I change it?

 

Upload ID of that happening: 2026_05_21_VJCrNQutLfckp1e3LBdnPV

PS: Also, I've put IntelliJ in the topic as there isn't a Rider topic?

0

xlysander12pt Could you please have a check if the symptom is caused by the confilct Live Template settings

It looks like you triggered the if live template then linter applys code format settings after that.

 

0

Hey Tao Sun, I've tried disabling the “Reformat” option and even editing the template to have the braces on the correct spot, but, even then, it didn't work. Also tried to change the option under “Use in” to “Generation” but still with no luck.

Funny thing, if I just write if and then try to use the template directly, it places the braces on the right spot without any “conflicts”.

 

0

xlysander12pt In the Settings | Editor | General | Typing Assistance, turn off auto-format on typing related settings, see if it helps to eliminate the flicker.

0

Tao Sun I've disabled “Auto-format on semicolon”, “Auto-format on closing brace”, “Auto-format on Paste → None”, “Smart indent on enter” and the problem persists.
Here are the settings as of now:

 

0

xlysander12pt If there is no other formatter provider, and code style settings under File | Settings | Editor | Code Style | C# have been configured matching with the K&R style (some directives like if may have particular configs there), you can export Layer-based Settings (in Settings | Manage Layers) and upload it here. I will have a check to see if it's reproducible.

A simple solution that can reproduce your issue would be helpful.

Share your Upload ID so that I can find it.

0

Hey there Tao Sun. I've uploaded both the machine layer and the solution layer settings. These can be found here: 2026_05_27_7XAtq4oLdZpzCZAsDQbfRb 

Thank you for your help!

0

请先登录再写评论。