Reputation: 6225
I'm new to Clojure and new to Emacs.
Is there an Emacs short-cut to intelligently re-indent the whole file? if not, is there at least a way to indent selected regions left or right?
I feel like I'm back in the stone age repeatedly pressing the arrows
Upvotes: 26
Views: 8781
Reputation: 10274
Use cljfmt for many configurable ways to reformat/reindent. It has an Emacs plugin, but also can be run via lein
.
Upvotes: 0
Reputation: 10274
When you capture data from a sequence like C-u C-c C-e
(cider-eval-last-sexp
), the raw data output to your buffer can be
unwieldy to inspect/work with. And the normal code-indenting commands
(mentioned in answers here) don't handle it well.
For handling results from such evaluated expressions, try
cider-format-edn-region
.
As a concrete example, have you ever tried reformatting your
~/.lein/profiles.clj
? This is pretty hard to do and keep
consistent, until you discover cider-format-edn-region
. Take
caution that it will, however, remove any comments.
Upvotes: 3
Reputation: 18499
C-x h selects the entire buffer. C-M-\ reindents the selected region.
Upvotes: 43