26 Dec 2013

Quite often in Emacs, especially when writing Clojure code, I want to reindent the entire file. I think that arises from the fact that I’m writing a lot of Lisp these days, and Lisp is the only language I’ve ever encountered where automatic indenting actually works well.

Anyway, here’s the code I use to map meta-shift-q to “reindent the whole buffer”:

(defun reindent-whole-buffer ()
  "Reindent the whole buffer."
  (interactive)
  (indent-region (point-min)
                 (point-max)))

(global-set-key (kbd "M-Q") 'reindent-whole-buffer)

Pretty simple, huh?

comments powered by Disqus