首页 > 解决方案 > 如何将文本与 Sublime 3 中的 Alignment 包对齐,并在“=”周围有空格?

问题描述

我想在 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": [
        "=", ":"
    ]
}

标签: alignmentsublimetext3

解决方案


默认设置显示:

:
:
// 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": ["="],
:
:

确认你的没有以某种方式被破坏。

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

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

如果我使用了多个游标,运行后,游标放在=静止的前面:

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

因此,要点是,无论我是否更改,我都无法复制您的问题alignment_chars

我建议将AlignTab包作为 Alignment 的替代品,因为“实时预览模式”很棒。


推荐阅读