Reputation: 27713
This is how VS2015 indents code (using "Format Document"):
void actual()
{
int i = 0;
if (i == 1)
Text = "a";
else
if (i == 0)
Text = "b";
else
Text = "c";
}
Is there a way to fix it to have corresponding if
and else
statements with the same indentation, and indented more than the previous indentation without adding brackets?
EDIT
I would expect it to be like in previous versions (VS 2010 and 2013):
void expected()
{
int i = 0;
if (i == 1)
Text = "a";
else
if (i == 0)
Text = "b";
else
Text = "c";
}
Upvotes: 0
Views: 850
Reputation: 16991
You have an if
with 3 branches that you are trying to treat as a 2 branch if
with another if
inside it. This doesn't seem to be a formatting problem, but rather a problem with the interpretation of how the branches work.
If you really want it as 2 separate if
s then you would have to write it this way:
void expected()
{
int i = 0;
if (i == 1)
Text = "a";
else
{
if (i == 0)
Text = "b";
else
Text = "c";
}
}
Upvotes: 1