Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top