- GNU indent style (which is the default, or indent -gnu)
- Kernighan & Ritchie indent style (invoked with indent -kr)
- original Berkeley indent style (invoked with indent -orig)
Thus, to indent a C source file using the Kernighan & Ritchie style, one would use:
indent -kr source.c
Have a look at the screenshots below:
Original, wrongfully formatted source code

Same code, formatted using indent source.c (using default GNU style)

Same code, formatted with the Kernighan & Ritchie style (with indent -kr source.c)

Notice that indent is developed to work with C code, not C++; also, it will try to cope with invalid code too.
No comments:
Post a Comment