Automatically indent multiple-line argument list in Visual Studio

When the list of method arguments grows to such an extent that it doesn’t fit on one line, I like to format the code so that each argument is on a separate line (as suggested by StyleCop), for example:

public void MyMethod( int someArgument, double someOtherArgument, int someMoreArguments) 

The problem I am facing is that this formatting is “fragile” and cannot be reformatted automatically when using Ctrl + K + D. For example, if I manage to insert some spaces before one of the arguments, it will not be deleted, and I end up doing tedious manual formatting. If I copy a method (for example, to provide an overloaded signature), the indentation of the argument in the copy becomes completely messy.
I have a similar problem with LINQ statements, which I also like to format on multiple lines, for example:

 myEnumerable. .Where(this and that) .Where(this and that) .FirstOrDefault(); 

I understand that this is full obsessive-compulsive formatting and a very minor problem, but is there a way to make Visual Studio 2010 automatically drag multi-line arguments following this pattern when it shifts?

+6
source share
1 answer

You can watch Resharper from JetBrains. It has all sorts of rules that can apply to code formatting, which is much better than the built-in VS material.

http://www.jetbrains.com/resharper/

This specific parameter is located at:

Update

Resharper> Options> C #> Formatting Style> Line Breaks and Wrapping> Wrap Long Strings

I don’t know if it does exactly what you want, but it completes long lines

+3
source

Source: https://habr.com/ru/post/894993/


All Articles