ReSharper Line Breaks and Wrapping

25,062

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.

Share:
25,062
ryancerium
Author by

ryancerium

Updated on August 01, 2020

Comments

  • ryancerium
    ryancerium almost 3 years

    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.

  • Marcelo De Zen
    Marcelo De Zen almost 11 years
    Hey @Dmitry Osinovskiy, maybe you have a clue about a problem I'm having with ReSharper 6.1? If you could, please take a look in my question: stackoverflow.com/questions/11622581/…
  • ryancerium
    ryancerium almost 11 years
    We're still on 6.1. I'm using a Right Margin of 100, so it should be plenty. It seems like, "Oh, this new OdbcCommand() is too long, put it on a new line. Oh, this string.Format() is too long, put it on a new line. Oh, this verbatim string is too long, put it on a new line." At least, that's how I imagine the algorithm working.
  • Dmitry Osinovskiy
    Dmitry Osinovskiy almost 11 years
    @devundef Unfortunately I don't have a clue. But you can always try to ask him twitter.com/fergard/status/228271877393633280
  • Mmm
    Mmm over 3 years
    As a new user to ReSharper, I'm surprised at how many defaults it has that I disagree with! This was one. Thanks for pointing out how to turn it off.
  • Dmitry Osinovskiy
    Dmitry Osinovskiy over 3 years
    @Mmm Select solution in Solution Explorer, Extensions > ReSharper > Edit > Detect formatting settings to find all of them at once
  • CyrilDex
    CyrilDex almost 3 years
    The option to turn off the wrapping of long lines is now located at Extensions > ReSharper> Options > Code Editing > C# > Formatting Style > Line Breaks and Editing > General > Wrap long lines. Simply un-check the check-box, if it is selected.