Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Resharper wrap very long lines properly?

Resharper's code formatting is generally fine, but it seems completely broken when dealing with very long lines. For example look at this piece of code:

enter image description here

I do want some kind of line wrapping, but it should look ahead and indent less if necessary to avoid ridiculous amounts of line breaks. Something like this would be great:

enter image description here

Is there any way to make Resharper do this?

like image 337
Adrian Grigore Avatar asked Mar 29 '11 18:03

Adrian Grigore


People also ask

How do you break a long code line in Visual Studio?

Use the line-continuation character, which is an underscore ( _ ), at the point at which you want the line to break. The underscore must be immediately preceded by a space and immediately followed by a line terminator (carriage return) or (starting with version 16.0) a comment followed by a carriage return.

How do I set rules in ReSharper?

Find the name of formatting rule that you want to tweak. You can look it up on the Code Editing | [Language] | Formatting Style page of ReSharper options ( Alt+R, O ) or alternatively, you can select a code block where the desired rule applies, press Alt+Enter , and choose Format selection | Configure.


1 Answers

Alex Berezoutsky of Jetbrains has suggested to turn off "Indent array, object and collection initializer" checkbox in the "ReSharper | Options | Languages | C# | Formatting Style | Other" dialog. It's not ideal IMO for shorter lines, but it does look much better on very long code lines.

I guess it's the best workaround for this problem at the current time.

like image 73
Adrian Grigore Avatar answered Sep 28 '22 03:09

Adrian Grigore