3

在 Emacs/Cider 设置中(建立在 clojure-mode 和 paredit-mode 之上),制表位通常被忽略。或者,假设它们仅缩进到 s 表达式的第二个符号。

有时,例如对于较大的配置,还需要缩进后续符号:

这将是默认值:

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

该怎么做,如果它应该看起来像:

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

2 回答 2

0

Emacs 不会按照您的意愿对齐 vector 中的元素,但是,您可以使用M-i( tab-to-tab-stop) 插入制表符(或多个空格取决于您的配置)。因此,您可以按照自己喜欢的方式手动对齐元素。

于 2016-08-19T12:49:36.240 回答
0

如果您可以忍受将配置作为地图而不是矢量,那么当您打开时,clojure-mode 会做正确的事情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})
于 2016-08-19T14:18:03.640 回答