在Sublime Text文档中,我看到TM_CURRENT_WORD
$TM_CURRENT_WORD Current word under the cursor when the snippet was triggered.
我对如何在实践中使用它感到困惑。光标下的单词总是不是tabTrigger中的单词吗?我试图使用这个参数将参数传递给Sublime片段,但不能让它正常运行。
答案 0 :(得分:0)
这个代码段对我来说很好用:
<snippet>
<content><![CDATA[
Before you insert snippet cursor was in this "$TM_CURRENT_WORD" word.${0}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>word</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text</scope>
</snippet>
there你可以找到一个非常有趣的例子:
<snippet>
<content><![CDATA[ = $TM_CURRENT_WORD + 1]]></content>
<tabTrigger>++</tabTrigger>
<description>i = i + 1</description>
<scope>source.fortran</scope>
</snippet>