No blank line for multiple attributes

Hi! I want something like this:

[Header("Group 1")]
[SerializeField] private GameObject go1;
[SerializeField] private TMP_Text label1;
[SerializeField] private Image image1;

[Header("Group 2")]
[SerializeField] private GameObject go2;
[SerializeField] private TMP_Text label2;
[SerializeField] private Image image2;

But 'Reformat Code' does this:

[Header("Group 1")]
[SerializeField] private GameObject go1;

[SerializeField] private TMP_Text label1;
[SerializeField] private Image image1;

[Header("Group 2")]
[SerializeField] private GameObject go2;

[SerializeField] private TMP_Text label2;
[SerializeField] private Image image2;

How can I get it? Thanks.

3 comments
Comment actions Permalink

Hello Dmitrii,

Try changing File | Settings | Editor | Code Style | C# | Line Breaks and Wrapping | Keep existing arrangement of attributes to true and Blank Lines | Around fields to 0. Let me know how it goes then.

0
Comment actions Permalink

Hi Olga Diakonova . It's working, Thanks!

But I want to save blank line for multiline fields without attributes. Is it possible to add something like a rule to ignore attributes in formatting rules? I often have auto formatting issues and have to disable common rules (like line wrapping, around field etc).

0
Comment actions Permalink

Dmitrii, if you have non-zero value in Preferences | Editor | Code Style | C# | Blank lines | Keep max blank lines in declarations, then Rider should not remove them. You can set up manually the way you like and Rider will keep it.

0

Please sign in to leave a comment.