VS v010 indent the following C++ code as:
if (Foo(arg1,
arg2))
{
}
Is there a way to change VS formatting rules to indent the code as below:
if (Foo(arg1,
arg2))
{
}
Thanks
Update
Why are those minuses? Don't you think guys code style is important or there'is some other reason?
Type in settings and select Open User Settings. In Search settings box, input indent to search for settings related to indentation. Select full in Editor: Auto Indent section. Automatic indentation is now enabled.
To do so, go to the Tools menu, click on Options -> Expand Text Editor, select a language, for example C# and click on General if is not selected automatically. Then, in the last section of the window named “Display”, enable the Line Numbers checkbox.
Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With