3

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 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@idleberg This is great when there is a single field in the snippet; any ideas on how to make it work when there are multiple fields within the same snippet without creating a new key binding as suggested in the answer to this question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.