3

I'm using uncrustify 0.56 and I'd like to know if it's possible to format constructors like that:

MyClass::MyClass(int arg1, int arg2, int arg3) : m_arg1(arg1), m_arg2(arg2), m_arg3(arg3) {}

// shall be formatted to

MyClass::MyClass(int arg1, int arg2, int arg3) : 
   m_arg1(arg1), 
   m_arg2(arg2), 
   m_arg3(arg3)
{
}

I couldn't find any option. Is this possible or is there another code beautifer/tool to achieve this kind of format?

Thanks in advance ...

janr
  • 3,664
  • 3
  • 24
  • 36

1 Answers1

3

Uncrustify 0.59:

# Whether to indent the stuff after a leading class colon.
# The term "class colon" refers to both 'class Dog: public Animal'
#                                                 ^
# and 'Dog::Dog(): Animal(), _fur(BLACK)'.
#                ^
indent_class_colon = true

# Add or remove a newline around a class colon.
# Related to <pos_class_colon>, <nl_class_init_args>, and <pos_comma>.
nl_class_colon     = force

# Add or remove newline after each ',' in the constructor member initialization.
nl_class_init_args = force

Currently, Uncrustify is the most flexible and configurable beast that I am aware of. I've tried tones of different code formatters in the past, including non-free ones. However, I found them to be either lacking some vital options or containing nasty bugs, these include: built-in code formatter of Eclipse CDT, AStyle, Jindent, and some others.

Alexander Shukaev
  • 16,674
  • 8
  • 70
  • 85
  • There is a default configuration file supplied with `Uncrustify`, all possible variables are defined there with good comments. You could just search for these variables there to see what do they mean. But anyway, it feels like their names are pretty self-documenting (at least those 3 above). – Alexander Shukaev Dec 22 '12 at 15:57
  • Well, I have updated the answer with descriptions of variables. – Alexander Shukaev Dec 22 '12 at 16:07