Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio indentaion of function arguments

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?

like image 661
dimba Avatar asked Dec 21 '11 07:12

dimba


People also ask

How do I automatically fix indentation in Visual Studio code?

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.

How do I show indentation in Visual Studio?

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.

How do I turn on auto indent in Visual Studio?

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.


1 Answers

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.

like image 142
Cody Gray Avatar answered Oct 04 '22 10:10

Cody Gray