61

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.

2
  • 3
    This doesn't look like any sort of default code formatting that Visual Studio does. Do you have an extension installed that may be changing how code gets auto-formatted? Commented Dec 26, 2012 at 17:13
  • Well, I have resharper installed. Maybe it is doing by resharpers. I will edit my post. Commented Dec 26, 2012 at 17:13

2 Answers 2

106

Solution for long lines:

ReSharper, menu OptionsCode EditingC#Formatting StyleLine Breaks And Wrapping.

And disable Wrap long lines:

Enter image description here

And it really makes me crazy!

Sign up to request clarification or add additional context in comments.

4 Comments

Nice to see Resharper in action! :D ;) <3
Option is now under Resharper > Options... > Code Editing > C# > Formatting Style > Line Breaks and Wrapping
plus 1 - "And it really makes me crazy."
@Felipe Oriani LIfe Saver
2

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.

1 Comment

Thank you Adam, but I found the solution in Reshaper Configs for long lines (my case).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.