Can GNU indent be made to format a while (or for, ...) statement to a single line?

My indent (GNU indent 2.2.11) outputs this

while (a == b)
    b++;

I'd like it to output one single line instead. I tried a lot of the options but haven't been able to come up with the right combination (it it's at all possible) yet.

while (a == b) b++;
for (i = 0; i < 100; i++) arr[i] = i;
link|improve this question
feedback

1 Answer

I can't do it using indent but using uncrustify. With:

uncrustify --show-config

you can see its configuration options, then you have to create the file ~/.uncrustify.cfg where you'll define your style. For what concerns your issue you must put in your configuration file:

nl_create_if_one_liner    True
nl_create_for_one_liner   True
nl_create_while_one_liner True

See man uncrustify to learn how to invoke uncrustify.

link|improve this answer
+1 Thank you cYrus. I've installed uncrustify and played a bit with it. I'll be testing it more deeply in the coming days. – pmg Oct 5 '10 at 18:20
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.