The answers to these, and similar questions is Komodo IDE's code formatting features. By feeding your code through a known formatter, Komodo IDE makes it easy to ensure your code is consistent and readable. You can even format your source files automatically upon saving via a user script. Let us explore these two ideas.
Komodo's formatting features live in the "Code > Format" menu and sub-menus. Given this untidy stream of HTML:
Piping it through Komodo's "Code > Format > Document using > XML Tidy" yields a much more tidy:
<html> <head> <title>Hi</title> </head> <body> <h1>Hello World!</h1> </body> </html>
Auto-Formatting on Save
Then, in the "Triggers" tab at the top of the dialog, check the "Userscript should trigger on a Komodo event", and then select "Before file save".
Now every time you save a source file, its associated formatter will run. If no formatter has been configured for your language, Komodo will discreetly remind you.
Dealing with badly, or potentially badly, formatted code should not be a hassle. Komodo IDE's code formatting features make this process easy by using existing and user-configured formatters, and by providing the ability to automate the process too.