Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

c# - 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.

question from:https://stackoverflow.com/questions/11744690/resharper-line-breaks-and-wrapping

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...