Auto-formatting C/C++ code...

I am in the process of refactoring a large project, and one problem that seems to come up is converting functions to and from the "one parameter per line" style.

e.g.

Convert...

Foo( param1, param2, param3 );

To...

Foo(
param1,
param2,
param3
);

or vice versa.

I am using both Visual C++ express ( Windows ) and XCode 4 (Mac), but I prefer to most of my coding in Visual C++ (it's a cross platform app).

I also use astyle to automatically format much of my code, but sadly it does not appear to have this feature.

So, is there a utility to do this, or a built in feature to one of these IDE's? I've been searching high and low, but cannot find a solution (perhaps not using the best key phrases to search for).

p.s. I also use Notepad++... any plug-ins for it to accomplish this?
Is this how you prefer it?
http://gist.github.com/4049161

You could always write your own program to do it. The syntax elements in C++ shouldn't be that difficult to deal with.
Last edited on
Is this how you prefer it?
http://gist.github.com/4049161

You could always write your own program to do it. The syntax elements in C++ shouldn't be that difficult to deal with.


Not really... with some functions with many parameters, and/or long names, ideally, I would like to simply highlight them, hit a hot-key, and convert it from one format to the other. Visual C++ does have an auto-format hotkey, but it does not handle this case.

Sometimes, the function may already have multi-lines, and I would prefer to condense it back down to a single line. Doing it manually is tedious, hence I am looking for a solution.

As for doing it myself, I fear that it would defeat the point of trying to save time, especially if a solution already exists. It's always better to not re-invent the wheel when possible :D :D :D
Artistic Style.
Indeed, I do use Artistic Style (astyle) as mentioned above, but as far as I know, it does not contain an option for making long function calls multi-line. If there is an option to do that, I'd love to hear about it. I LOVE Artistic Style :D
Oh, sorry. That's what I get for just skimming posts.
Checkout gnu indent with the bfda flag
http://www.gnu.org/software/indent/manual/indent.html
Topic archived. No new replies allowed.