Following one liner attempts to format your codes. Works on programs of perl, c, php etc where curly braces - '{ and }', are used for blocks, loops, conditions etc.
perl -pe '$tabs = substr($tabs,1) if (/^\s*}\s*$/);s/^\s*/$tabs/;$tabs.="\t" if(/{[^}]*$/);' -i.bk filename.c
Files are backed up with .bk extension.
Wildcards are allowed so *.c can be used in place of filename.c.
Thursday, June 29, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment