views:

344

answers:

3

When I type this line of code:

QString newPath = QFileDialog::GetOpenFileName(this, tr("Open Image"), path, tr("Image files (%1)").arg(formats.join(" ")));

I typically format it like this:

QString newPath = QFileDialog::GetOpenFileName(this, 
                                               tr("Open Image"),
                                               path, 
                                               tr("Image files (%1)").arg(formats.join(" ")));

i.e. I like to align the function parameters vertically, having each parameter on its own line.

Is there some Visual Studio add-on that could automatically do this?

Would be nice if I could just press some key combo to automatically format code (similar to Netbeans Alt+Shift+F, I believe)

UPDATE: This code formatter works great for standard C++ application, but doesn't work right in my Qt application. Oh wellz, cant have everything, right?

+1  A: 

ProFactor's StyleManager will do this from within Visual Studio, for a fairly inexpensive price.

Reed Copsey
wow...i wish i had asked this question a lot sooner so that I dont have to do all that formatting manually myself.It's a good, intuitive tool. Thanks!
ShaChris23
+2  A: 

You can format code like that by selecting it and pressing Ctrl-K + Ctrl-F! It's also in the menu at Edit / Advanced / Format Selection

henle
I don't recall the built-in VC++ formatter doing what is asked in the question.
Pavel Minaev
You have to break up the function call yourself. I'm guessing you usually want short function calls on one line. But the aligning is done automatically.
henle
Haha, who am I to tell you, looking at your profile ;)
henle
A: 

Have you tried the build in Visual Studio formatter (usually CTRL+K then CTRL+D).

You may need to play with the "Indenting" option at Tools\Options\Text Editors\C++\Tabs

Shay Erlichmen
Ctrl+F is find?
ShaChris23