在另一个代码片段内部时,如何展开一个代码片段? [英] How do I expand a snippet, while inside of another snippet?
问题描述
在Sublime Text 3中,我试图在一个代码段内插入一个代码段,又名
In Sublime Text 3, I'm trying to insert a snippet inside of a snippet, aka
ul[TAB]
产生
<ul>|</ul>
,将光标嵌套在元素之间。
with the cursor nested between the elements.
现在,我想做的就是能够在此代码段内扩展另一个代码段,又称
Now, what I'd want to do is be able to expand another snippet inside of this snippet, aka
ul[TAB]li[TAB]
渲染
<ul><li>|</li></ul>
再次将光标嵌套在元素之间,不幸的是,它成为了崇高文字3中的片段的一部分,[ TAB]将您带到下一个锚点,在这种情况下,退出标签。我发现此功能非常方便,但在这种情况下是PITA。上面列出的击键将呈现:
once again with the cursor nested between the elements, unfortunately as part of snippets in sublime text 3, [TAB] brings you to the next anchor point, in this case, exiting the tag. I find this feature incredibly handy, but in this case, a PITA. The above listed keystrokes would render:
<ul>li</ul>|
,光标位于结束标记之后。
with the cursor after the closing tag.
是否可以退出该代码段,以便随后输入新的代码段?
Is there a way to exit out of the snippet, so that I can then enter a new snippet?
推荐答案
您可以使用 $ 0
来指定光标的位置:
You can specify the position of the cursor using $0
, example:
<snippet>
<content><![CDATA[
<ul>$0</ul>
]]></content>
<tabTrigger>ul</tabTrigger>
<scope>text.html</scope>
</snippet>
我建议您看一下出色的 Emmet 插件,因为它使嵌套HTML标签的支架非常容易。
I recommend taking a look at the excellent Emmet plugin, as it makes scaffolding of nested HTML tags pretty easy.
这篇关于在另一个代码片段内部时,如何展开一个代码片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!