Which editor are you using? Xcode, TextMate, vim, emacs, nedit, something else?
Most text editors meant for editing source have a code beautifier for prettyprinting and auto indentation. Then there are always command line utilities like indent(1) that will do this for you after the fact.