修改引号的 auto_match,为 Sublime Text 2 添加一个额外的引用字符 [英] Modify auto_match of quotes, adding an additional quoting character to Sublime Text 2

查看:18
本文介绍了修改引号的 auto_match,为 Sublime Text 2 添加一个额外的引用字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sublime Text 2 非常有帮助地结束了我所有的引述.
是否可以修改它使用的字符?

Sublime Text 2 very helpfully closes all of my quotes.
Is it possible to modify which characters it does this with?

例如,如果我想将 `backticks` 添加到列表中.

For example, if I would like to add `backticks` to the list.

@skuroda 的回答非常有效.在 Mac OSX 上,转到

@skuroda's answer works great. On Mac OSX, go to

Sublime Text 2 >首选项 >键绑定 - 用户

并在那里粘贴文本.确保它最终包含在 [...](方括号)中.

and paste in the text there. Make sure it is ultimately wrapped in [...] (square brackets).

推荐答案

自动配对只是一些专门的键绑定.这应该允许您自动配对反引号.如果您想创建其他自动配对符号,它还应该作为指南.

The auto pairing is simply a few specialized keybindings. This should allow you to auto pair backticks. It should also serve as a guide for if you want to create other auto paired symbols.

{ "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": "^(?:	| |\)|]|;|\}|$)", "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 }
    ]
}

只需将该代码块插入到您的用户键绑定中即可.

Simply insert that code block into your user key bindings.

我只是使用默认键绑定作为模板,因此您可能需要进一步修改一些上下文以使其完美运行.

I just used the default keybinding as a template, so you may need to further modify some of the context to get it to work perfectly.

这篇关于修改引号的 auto_match,为 Sublime Text 2 添加一个额外的引用字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆