views:

291

answers:

2

I use astyle to format my code most of the time, and I love it, but one annoyance is that it can't specify at least a "hint" for max line length. If you have a line of code like:

this->mButtonCancel->setLeftClickProc(boost::bind(&FileListDialog::cancelLeftClick, this));

I would like a source code formatter to be able to wrap it even moderately intelligently:

this->mButtonCancel->setLeftClickProc(
  boost::bind(&FileListDialog::cancelLeftClick, this));

...is probably how I would format that line of code. For long argument lists, I would probably prefer to align on the open parenthesis, but clearly that won't work in this situation. Either way, astyle doesn't support doing anything with long lines that don't contain multiple statements. Does anyone know of a tool that does?

+1  A: 

If you google "Beautify C Code" you will find some nice utilities. I know on *nix there is a binary called bc that does some basic formatting. It is not very customizable, though.

Raj More
+4  A: 

GNU Indent has support for breaking long lines.

http://www.gnu.org/software/indent/manual/indent.html#SEC12

alxv
Perhaps some combination of astyle and indent would do the trick...
Nick Bastin