Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an automatic source code formatter that nicely wraps lines of C/C++? [closed]

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?

like image 604
Nick Bastin Avatar asked Nov 29 '22 07:11

Nick Bastin


1 Answers

GNU Indent has support for breaking long lines.

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

like image 137
alxv Avatar answered Dec 01 '22 20:12

alxv