3

In an Emacs/Cider setup (which is build on top of clojure-mode and paredit-mode), tab stops are usually ignored. Or, say they indent just to the second symbol of an s-expression.

Sometimes, e.g for larger configurations, it's desirable to indent also the subsequent symbols:

This would be the default:

(def config [:hello 34 :goodbye
             :a 34 :c
             :long-word 0 :a])

What is to do, if it should look like:

(def config [:hello      34   :goodbye
             :a          34   :c
             :long-word  0    :a])
Anton Harald
  • 5,772
  • 4
  • 27
  • 61

2 Answers2

0

Emacs will not align the elements in vector as you wish, however, you can use M-i (tab-to-tab-stop) to insert tab (or multiple spaces depends on your config). So you can manually align the elements like the way you like.

ntalbs
  • 28,700
  • 8
  • 66
  • 83
  • that's good to have! It would be even better if clojure-align was enhanced to work with any collection. https://github.com/clojure-emacs/clojure-mode/blob/464c9de6734cb4b426137674041d695c2a7c7ef9/clojure-mode.el#L973 – Anton Harald Aug 19 '16 at 13:05
  • Feel free to file a ticket. We didn't consider such an usecase, but we might implement it in the future. – Bozhidar Batsov Aug 21 '16 at 15:58
0

If you can live with having your config as a map instead of a vector, clojure-mode does the right thing when you switch on clojure-align-forms-automatically:

(def config {:hello 34
             :goodbye [something else]
             :a [34 :c]
             :long-word 0
             :a 'b})

=>

(def config {:hello     34
             :goodbye   [something else]
             :a         [34 :c]
             :long-word 0
             :a         'b})
Joost Diepenmaat
  • 17,633
  • 3
  • 44
  • 53