带有 tabTrigger 参数的 Sublime 片段 [英] Sublime snippet with params on tabTrigger
问题描述
例如我输入的 .html 文件中的某处:
For example somewhere inside .html file i type:
temp:some-id
并期望我的代码段创建魔法返回带有指定some-id"的:
And expect my snippet creation magic to return this with the specified "some-id" :
<script type="text/template" id="some-id"></script>
所以我需要一种方法来触发一些文本并将一些参数传递给代码段创建文件,这样当触发发生时,我可以将这些参数分配给 .sublime-snippet 中的一些制表符占位符.有什么想法吗?
So i need a way to trigger some text and pass through some arguments to the snippet creation file so when the triggering happens I can assign that arguments to some tab-placeholder inside .sublime-snippet. Any ideas?
附言如果重要的话,我正在使用 sublime text 2.
P.S. im using sublime text 2, if it matters.
推荐答案
你应该使用变量 $TM_CURRENT_WORD
,你可以看看这个 页面了解更多详情
You should use the variable $TM_CURRENT_WORD
, you can look into this page for more detail
但是在测试时我注意到如果我有代码段:
However when testing this I noticed that if I have the snippet:
Hello, $TM_CURRENT_WORD
使用触发器 hello:
在 :
之后直接加上我想要的词,例如 hello:user
我必须有 user
突出显示,如果我想要一个选项卡来触发我的代码段,那么在这种情况下它应该与变量 $SELECTION
一样正常工作.
with the trigger hello:
with my desired word directly after :
something like hello:user
i must have user
highlighted if I want a tab to trigger my snippet so it should work just as fine with the variable $SELECTION
in this case.
希望这会有所帮助.
这篇关于带有 tabTrigger 参数的 Sublime 片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!