Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper Line Breaks and Wrapping

So, this:

cmd = new OdbcCommand( string.Format( @" SELECT *   FROM Bobby_Tables  WHERE Name = {0}", "Little Bobby Drop Tables" ), odbcConnection ); 

gets formatted to:

cmd =        new OdbcCommand(              string.Format(                    @" SELECT *   FROM Bobby_Tables  WHERE Name = {0}",                    "Little Bobby Drop Tables" ), odbcConnection ); 

I've looked at each of the options for line breaks and wrapping but I haven't been able to find the one to keep things on the same line as long as possible. I'm assuming that I missed the correct option. My Right margin (columns) option is set to 100, which is plenty big.

Question: Is there a way to make it look like the original, and still get smart formatting on other things that actually do need to be wrapped?

I can manually put the

cmd = new OdbcCommand( string.Format (       @" 

back on the first line and it'll leave the verbatim string on the next line happily. That's an alright compromise I guess.

like image 331
ryancerium Avatar asked Jul 31 '12 16:07

ryancerium


People also ask

How do I set rules in resharper?

Select the scope where you want to reformat code: Make a selection in the editor to reformat code in the selection. Set the caret anywhere in the file to reformat code in the file. Select one or more items in the Solution Explorer to reformat code in files under these items and their child items.

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.


1 Answers

I guess that your problem is that the first line got broken in three. This is because of bug http://youtrack.jetbrains.com/issue/RSRP-288271 that was fixed in ReSharper 7.0. You should consider upgrading or turning off option ReSharper | Options -> Code Editing | C# | Formatting style | Line breaks and wrapping -> LineWrapping | Wrap long lines.

like image 83
Dmitry Osinovskiy Avatar answered Sep 23 '22 21:09

Dmitry Osinovskiy