Tabbing your code is really something you want handled by your text editor. What text editor are you using?
Most emacs modes do this automatically. For languages with braces like C++, Perl, or Ruby you just hit tab on any line, and it automatically indents it correctly. For languages like Python tab will cycle through the possible acceptable indentations.
Other text editors like Eclipse (and I believe vi) will indent correctly by default when you hit enter, but after that nothing is automatic. But that's pretty good too.