简体   繁体   中英

indent configurations in emacs cider/paredit/clojure-mode

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, eg 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])

Emacs will not align the elements in vector as you wish, however, you can use Mi ( 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.

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})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM