如何将文本与 Sublime 3 中的 Alignment 包对齐,'=' 周围有空格?

How to align text with Alignment package in Sublime 3 with spaces around '='?

我想使用 Sublime Text 3 中的 Alignment 包来对齐一些变量赋值,我想在 = 字符周围留出空格。这是一个例子:

bar = 'cherry'
bar_baz = 'tomato'
f = 'carrot'

结果是这样的:

bar    = 'cherry'
bar_baz= 'tomato'
f      = 'carrot'

应该是这样的:

bar     = 'cherry'
bar_baz = 'tomato'
f       = 'carrot'

我对 Alignment 包的设置如下:

{
    "alignment_chars": [
        "=", ":"
    ]
}

默认设置显示:

:
:
// The mid-line characters to align in a multi-line selection, changing
// this to an empty array will disable mid-line alignment
"alignment_chars": ["="],

// If the following character is matched for alignment, insert a space
// before it in the final alignment
"alignment_space_chars": ["="],
:
:

确认你的没有被损坏。

使用您的输入,如果我 select 文本,或者我在 = 和 运行 命令前使用多个光标,它将按照您指定的方式对齐, = 周围的空格,例如:

bar     = 'cherry'
bar_baz = 'tomato'
f       = 'carrot'

如果我用了多个游标,在运行ning之后,游标放在=前面的还是:

bar     |= 'cherry'
bar_baz |= 'tomato'
f       |= 'carrot'

所以,要点是,无论是否更改 alignment_chars,我都无法重现您的问题。

我建议查看 AlignTab 包作为 Alignment 的替代品,因为 "Live Preview Mode" 很棒。