How to wrap / chop long lines in cshtml @(...) codeblock

We have an @(...) codeblock in a .cshtml file. This block starts with a lot of concatenated Function calls like  Foo.Do().Some().Thing()... and is 500 chars long.

The Context Actions Chop / Wrap long lines are available, but do nothing when selected.

Reformatting the code via Code -> Reformat Code does nothing.

When I Chop the code manually and hit reformat the codeblock gets reformatet as a single line again.

How can I configure Rider to format this code? If thats not possible how can I force Rider to respect my manual formatting?

I know about putting // at the end of lines to enfore linebreaks, but I'd rather avoid this.


1 comment

Hello Thomas Schreiner, thank you for your question. There is the following issue about this problem in our bug tracker: Please comment or vote for it to get notifications about status changes.

Also, I'd like to mention about some settings. In order for manual formatting to be preserved, you need to enable File | Settings | Editor | Code Style | C# | General | Keep existing line breaks. Please also take a look at File | Settings | Editor | Code Style | C# | Line Breaks and Wrapping | Arrangement of Member Access Expressions | Wrap chained method calls, perhaps it will help you to set it to Chop always. Please let me know if you have any questions. Thank you!


Please sign in to leave a comment.