修改auto_match报价,增加一个额外的引用字符崇高文字2(Modify auto_match

2019-09-01 18:25发布

崇高的文本2非常有益关闭所有我的报价。
是否有可能修改它做到这一点的字符?

例如,如果我想一段单列加上`到列表中。


@ skuroda的答案的伟大工程。 在Mac OSX,去

Sublime Text 2 > Preferences > Key Bindings - User

并粘贴在文本那里。 请确保它最终被包裹在[...]方括号)。

Answer 1:

自动配对仅仅是少数专业的按键组合。 这应该允许您自动对反引号。 这也应作为,如果你想创建其他自动配对符号的指南。

{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
    ]
},
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$SELECTION}`"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
    ]
},
{ "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true }
    ]
},
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Left Right.sublime-macro"}, "context":
    [
        { "key": "setting.auto_match_enabled", "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 }
    ]
}

只需插入代码块到您的用户密钥绑定。

我只是用默认的按键绑定作为模板,所以你可能需要进一步修改一些上下文得到它完美地工作。



文章来源: Modify auto_match of quotes, adding an additional quoting character to Sublime Text 2