0

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;
0

1 Answer 1

2

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.

1
  • +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, 2010 at 18:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .