Custom Search

Saturday, February 28, 2009

Linux Command Line to format c source file

In Linux system you can use this command line to format your c source file :

> indent -i4 -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -l90 foo.c

You may want to put these settings in your ~/.indent.pro to automatically invoke this configuration next time.

In verbose, the above means:

* -i4: indent level 4
* -ts4: tab size 4
* -br: braces on if line
* -brs: braces on struct decl line
* -cdw: cuddle do while
* -lp: line up continuation below parenthesis
* -ce: cuddle else
* -nbfda: dont break function decl args
* -npcs: no space after function call names
* -nprs: no space after parentheses
* -npsl: dont break procedure type
* -saf: space after for
* -sai: space after if
* -saw: space after while
* -cs: space after cast
* -ln90: line length 90 columns

No comments: