默认情况下,卓异意志自动对引号仅当下列字符是\t
(制表符)之一,
(空间),)
,]
,}
,>
,或在该行的末尾。幸运的是,通过创建基于默认密钥绑定的自定义密钥绑定,可以轻松修改此规则。开放Preferences -> Key Bindings-User
并添加以下(如果该文件是空的,环绕一切与在开始时的开口方括号[
并在结束[ <content> ]
闭]
):
// allow matched quotes before semi-colon
// double quotes
{ "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 },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }
]
},
// single quotes
{ "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 },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "['a-zA-Z0-9_]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single", "match_all": true }
]
},
// curly brackets
// parentheses and square brackets already work
{ "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 }
]
}
每个规则中的关键线是这样的:
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$|;)", "match_all": true },
如果你发现你想自动对之前另一个角色,只是把一管|
分号之后"operand"
并添加你想要的角色。
我应该注意到,这将在崇高的文字2和3两个工作。
一个_outstanding_答案,谢谢! – trejder 2014-09-25 21:53:01
@trejder很高兴我能帮到你! – MattDMo 2014-09-25 22:02:39