I'm working in a C# project and using Visual Studio 2012. When Visual Studio tries to format my code, it breaks lines and make my code look difficult to read. The original code (what looks pretty nice to read for me and my team):
if (list.Any(x => x.Type == (int) EnumType.Customer)) { }
And when Visual Studio tries to format:
if ( list.Any( x => x.Type == (int) EnumType.Customer)) { // Other break codes }
There are a lot of other parts where it is breaking my code. I like auto formatting for some parts, but my question is: Is there a way to disable this break lines from auto formatting in Visual Studio?*
PS: I also have ReSharper installed.
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.
Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
For Windows, Pressing Alt+Z will break the line. Show activity on this post. This setting will wrap your words according to your editor: viewport.
Solution for long lines:
ReSharper, menu Options → Code Editing → C# → Formatting Style → Line Breaks And Wrapping.
And disable Wrap long lines:
And it really makes me crazy!
In ReSharper's settings, in the Languages section, you can change the formatting style of your C# code. The option you're looking to disable is something along the lines of "Indent anonymous method body." You can also look through the options to further customize the formatting style to your preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With