Try this: C-x h C-M-\ C-x h runs the command mark-whole-buffer C-M-\ runs the command indent-regionYou can also insert something like: (defun indent-buffer () (interactive) (save-excursion (indent-region (point-min) (point-max) nil))) (global-set-key [f12] 'indent-buffer)If you want to rewrap comments afterwards, see CodeBeautifying. See also: package format-all CategoryIndentation This work is li