我正在尝试制作一个会在包含空格的文本块上触发的片段,即在键入ALTER AGGREGATE
并按 Tab 之后我想要片段触发:
<snippet>
<content><![CDATA[triggered]]></content>
<tabTrigger>ALTER AGGREGATE</tabTrigger>
</snippet>
但不幸的是,这不起作用。
然后我尝试使用escape for space:<tabTrigger>ALTER AGGREGATE</tabTrigger>
,但这也不起作用。
这有可能吗?
答案 0 :(得分:0)
Snippet选项卡触发器不能包含Sublime Text认为是单词分隔符的任何内容。
但是,如果要将触发文本保留在文档中,可以使用键绑定来模拟此触发器:
string code = Request.QueryString["code"];
string clientid = Request.QueryString["client_id"];
这假设您已将代码段保存在名为{ "keys": ["tab"], "command": "insert_snippet", "args": { "name": "Packages/User/alter_aggregate.sublime-snippet" },
"context":
[
{ "key": "preceding_text", "operator": "regex_match", "operand": "\\bALTER AGGREGATE$", "match_all": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "source.sql", "match_all": true },
]
},
的{{1}}文件夹中。
示例代码段内容(注意它缺少Packages/User
但以空格开头:
alter_aggregate.sublime-snippet
然后,输入ALTER AGGREGATE
Tab 会给你:
<snippet>
<content><![CDATA[
${1:myavg(integer)} RENAME TO ${2:newname};
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.sql</scope>
</snippet>
最初选择ALTER AGGREGATE
并按 Tab 会将其移至ALTER AGGREGATE myavg(integer) RENAME TO newname;
,以方便使用。