Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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;
share|improve this question

1 Answer 1

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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