问题
For some reason, after I type the following block in Visual Studio 2013:
for (int i = 0; i < m; i++)
if (some_condition)
{
}
VS 2013 automatically indents the code to this:
for (int i = 0; i < m; i++)
if (some_condition)
{
}
If I put the if between curly brackets, it formats the code correctly. This behavior is very frustrating. I don't remember having this issue in VS 2012.
If I disable auto formatting, it doesn't even put the cursor at the same indent level as the line above. Even notepad++ works better than VS.
Is there a way to fix this? Maybe to import the indenting rules from VS2012 which worked just fine?
回答1:
Bug is fixed with VS 2013 Update 1. Try install it Tools -> Extensions and Updates -> Updates -> Product Updates -> Update 1
回答2:
Can you change settings as below and check
In Tool->Options->Text editor->C/C++->Format-> Indentation (un-check this option) and reformate code block once or try new code.
来源:https://stackoverflow.com/questions/20491828/visual-studio-2013-c-auto-indenting-doesnt-work-well