Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

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

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

After formatting (the blank line is gone):

C#
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 14-Jan-20 23:29pm

I use VS 2017 but have never seen this issue. Check the formatting options in the editor:
Tools -> Options -> Text Editor -> Formatting.
 
Share this answer
 
It doesn't happen to me either:
C#
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:
C#
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 ...
 
Share this answer
 
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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900