you can record a keyboard macro, save it, assign it a key. So, just
press one key, and the file is indented and well-formatted.
〈Emacs: Using Keyboard Macro to Record/Playback Keystrokes〉
http://ergoemacs.org/emacs/emacs_macro_example.html
to indent, just select all then 【Ctrl+Alt+\】.
or, this can be easily done by writing a elisp command.
Xah