Home > Software design >  Can ReSharper remove blank lines before and/or after single line statements?
Can ReSharper remove blank lines before and/or after single line statements?

Time:01-22

Are there any code formatting options in ReSharper to make this code:

public string PublicMethod1(string parameter)
{
    parameter  = "Hello";

    parameter  = " ";

    parameter  = "world!";

    return parameter;
}

look like this:

public string PublicMethod1(string parameter)
{
    parameter  = "Hello";
    parameter  = " ";
    parameter  = "world!";
    return parameter;
}

I am currently using Visual Studio Professional 2019 and ReSharper 2021.3.2. Thanks in advance.

CodePudding user response:

Yes, set option Keep max blank lines in code to 0:

ReSharper > Options > Code Editing > C# > Formatting Style > Blank Lines

Value 3:

void Method() {
  foo();



  foo();
}

Value 0:

void Method()
{
    foo();
    foo();
}
  •  Tags:  
  • Related