Reputation: 11728
Is there a way to automatically correct the indentation of an entire buffer (or region) when editing javascript files with js2-mode in Emacs?
Upvotes: 3
Views: 838
Reputation: 14065
C-M-\
runs indent-region
. If you want to indent the entire buffer, you can do so with C-x h
(mark-whole-buffer
) followed by C-M-\
.
Upvotes: 4
Reputation: 5867
I use this regularly to clean up things
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(indent-buffer)
(untabify-buffer)
(delete-trailing-whitespace)
(delete-trailing-blank-lines))
(global-set-key (kbd "C-c n") 'cleanup-buffer)
UPDATE:
to be precise answer for your question. try M-x indent-buffer
Upvotes: 2