Click here to Skip to main content
14,427,367 members
Rate this:
Please Sign up or sign in to vote.
See more:
When reformatting, empty lines are deleted. But I want to keep them. Where do I set this? Thanks in advance.

Example:

Before formatting:

if(a == b)
{
   b = a;
}

if(a == b)
{
   b = a;
}

After formatting (the blank line is gone):

if(a == b)
{
   b = a;
}
if(a == b)
{
   b = a;
}


What I have tried:

Going thru the editor options but didn't find anything.
Posted
Updated 15-Jan-20 0:29am
Rate this:
Please Sign up or sign in to vote.

Solution 1

I use VS 2017 but have never seen this issue. Check the formatting options in the editor:
Tools -> Options -> Text Editor -> Formatting.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

It doesn't happen to me either:
int a = 1, b = 2;
if(a == b)
{
   b = a;
}

if(a == b)
{
   b = a;
}
If I then reformat using CTRL+K,D I get a better looking version:
int a = 1, b = 2;
if(a == b)
    {
    b = a;
    }

if(a == b)
    {
    b = a;
    }
but the line doesn't vanish. And I haven't turned on any options like that, most of my formatting options are defaulted.

Have you perhaps installed a "code style" extension which is doing it? I believe resharper can ...
   
Comments
Ken Guru 15-Jan-20 7:31am
   
Hi,

if you delete the last } (Namespace) in your file and add it again, is the result the same?
OriginalGriff 15-Jan-20 7:41am
   
I only have one namespace in the file!
Dave Kreskowiak 15-Jan-20 9:05am
   
I think he means remove the namespace closing brace and then re-add it. I doubt that will do anything at all, but...
OriginalGriff 15-Jan-20 10:03am
   
That will do a reformat on the brace contents, but so does CTRL-K,D ... :laugh:
Dave Kreskowiak 15-Jan-20 10:23am
   
:) As a side, your choice of brace positioning is triggering my OCD. I have a compulsion to move the braces left a tab.

OriginalGriff 15-Jan-20 10:37am
   
You leave them alone! Wars have started for less! :D
Dave Kreskowiak 15-Jan-20 15:40pm
   
~ ~ T R I G G E R E D ! ~ ~

:laugh:
Rob Philpott 15-Jan-20 11:45am
   
Quite right! I feel ill.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100