uncrustify

uncrustify: can I control where it decides to break apart lines?


I've been trying out uncrustify and while I've gotten a lot of mileage out of how configurable it is, I found it occasionally decides to break apart lines in ways I don't agree with.

Some examples:

void functionWithLongName(int parameter1, int parameter2, int parameter3, int parameter4) {
}

..becomes:

void functionWithLongName(int parameter1, int parameter2, int parameter3, int
                          parameter4) {
}

I'd rather have it be:

void functionWithLongName(int parameter1, int parameter2, int parameter3,
                          int parameter4) {
}

...as I'd prefer for it not to break apart the type and variable name, as well as any qualifiers.

Another example:

ClassName::ClassName(int importantValue) : memberVariable1(0), memberVariable2(importantValue), memberVariable3(0) {}

...becomes:

ClassName::ClassName(int importantValue) : memberVariable1(0), memberVariable2(
        importantValue), memberVariable3(0) {}

But I don't want it to break between the parentheses of one of these initializers. I'd much prefer something like:

ClassName::ClassName(int importantValue) : memberVariable1(0),
    memberVariable2(importantValue), memberVariable3(0) {}

Going through crustify's docs I haven't found settings that lets me specify this. Is there a way to do this?

In case it helps, here is my current uncrustify config file.


Solution

  • It looks like the problem was having ls_code_width set to true. Once I set it to false, uncrustify now seems to try to maintain groupings.