tags:

views:

102

answers:

2

ESS allows us to indent a line and an expression. Is there a key binding for indenting a buffer? If not, can we create it?

+4  A: 

Not sure about a buffer but you can mark a region and then use C-M-\ on it.

Dirk Eddelbuettel
Or mark the whole buffer with `C-x h`.
Nicholas Riley
Ah. As always with Emacs, one learns something new every day. Or I guess one should. :)
Dirk Eddelbuettel
+5  A: 

As stated by others you could mark the whole buffer C-x h and then indent the region with C-M-\

You could also put something along these lines in your .emacs file:

(defun my-indent-buffer()
  (interactive)
  (save-excursion
    (indent-region (point-min) (point-max))))

(global-set-key "\C-cib" 'my-indent-buffer)

This has the benefit of remembering your point.

kjfletch