首页 > 解决方案 > 如何自动添加新行并缩进崇高文本中的反引号?

问题描述

使用崇高的文本。类似于添加新括号 { 并按 Enter 键时,它会创建一个新的缩进块,如下所示(... 是空格):

{
....
}

当我使用反引号时,我希望同样的事情发生(因为我使用的是 stlyed-components)。

所以当我输入 `+enter 时,我会得到:

`
....
`

我怎么做?

标签: sublimetext3auto-indent

解决方案


您将需要一个新的键绑定Enter,具有特定条件。打开Preferences → Key Bindings并在右侧添加以下内容:

    { "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context":
        [
            { "key": "setting.auto_indent", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "`$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
        ]
    },

这只会在您打开"auto_indent"设置、选择为空并且光标前后的字符是反引号时运行。


推荐阅读