1

When trying to indent a block of code in Visual Studio 2012, by highlighting the code and hitting tab the editor is adding the if expression is true

if (true)
{

    ... // mycode block

}

I imagine I should be able to turn this off with the option settings in

Tools->Options->C/C++->Formatting

but haven't figured out which one, any ideas?

1 Answers1

1

This was driving me crazy as I noticed it was adding a 'for loop' then I realised it was when I was selecting code with a comment after the last brace, e.g

// code

for(...)
{
    // code block
} // for <- culprit

would become...

for (int i = 0; i < length; i++)
{
    // code block

    // original code 
    for(...)
    {
        // for loop code block
    } // for <- culprit

} // 

if I had } // switch it would delete the code block and enter the below

switch (switch_on)
{
default:
    break;
}

Still haven't found the option to turn this off, but at least I understand what the editor is trying to do