How do I expand a snippet, while inside of another snippet?

柔情痞子 提交于 2019-12-10 10:24:44

问题


In Sublime Text 3, I'm trying to insert a snippet inside of a snippet, aka

ul[TAB]

which produces

<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]

rendering

<ul><li>|</li></ul>

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?


回答1:


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>

I recommend taking a look at the excellent Emmet plugin, as it makes scaffolding of nested HTML tags pretty easy.



来源:https://stackoverflow.com/questions/23236247/how-do-i-expand-a-snippet-while-inside-of-another-snippet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!