Visual Studio 2010 indents the following C++ code as:
if (Foo(arg1,
arg2))
{
}
Is there a way to change Visual Studio formatting rules to indent the code as below:
if (Foo(arg1,
arg2))
{
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there’s no way “out of the box” to force Visual Studio to indent code that way. It’s always going to indent wrapped function parameters with only a single tab.
It turns out that such a style is in accordance with Microsoft’s general coding guidelines, and probably why they’ve written it that way. I don’t much care for it either, though, also preferring your style.
But it turns out that you only have to manually indent the first wrapped parameter. Subsequently, when you press Enter, Visual Studio will automatically start the next line underneath your first carefully lined up parameter.
Also remember that (if you’ve already written the method definitions), you can select multiple lines at a time and use the Tab key to line them all up. You don’t have to do one at a time.
In general, there are unfortunately extremely limited code formatting options available for C/C++ code in Visual Studio. The C# programmers get a lot more goodies. You might be able to invest in an add-in or extension like Visual Assist X that gets you more features in the IDE.