【问题标题】:How do I auto add new lines and indent to a backtick in sublime text?如何自动添加新行并缩进崇高文本中的反引号?
【发布时间】:2021-04-28 13:47:08
【问题描述】:

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

{
....
}

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

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

`
....
`

我该怎么做?

【问题讨论】:

    标签: sublimetext3 auto-indent


    【解决方案1】:

    您需要一个新的 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" 设置、选择为空且光标前后的字符为反引号时才会运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-12
      • 1970-01-01
      相关资源
      最近更新 更多