简体   繁体   中英

Sublime Text 2: Embed snippets inside snippets

I have been looking for over 40 minutes for any information about embedding snippets inside snippets using Sublime Text 2

I want to do something like

<snippet>
    <content> <![CDATA[Header content here]]> </content>
    <tabTrigger>header</tabTrigger>
    <scope>source.php</scope>
    <description>Function</description>
</snippet>

Above is the header snippet I would like to embed inside the below, content snippet

<snippet>
    <content> <![CDATA[

    ${trigger:header}

    Content Body Goes Here

    ]]> </content>
    <tabTrigger>content</tabTrigger>
    <scope>source.php</scope>
    <description>Function</description>
</snippet>

If there is nothing like this out there already, I would really like to know how I can add the

${trigger:<tabTrigger>}

command to the existing snippet functionality by creating an extension or plugin...

Any ideas, links to how I can add the ${trigger:} command, or links to an existing plugin that already does this, are greatly appreciated!

Thank you! - Jeff

Don't think it is possible. You can have the same trigger for multiple snippets (don't ask why, I'm just saying you can), so it's not really something you you can reference.

I can think of a few solutions though. All of them are probably suboptimal, but I'll list them anyways. Perhaps one of them will give you an idea.

  1. Set things up so you can manually enter snippets (or other autocompletions) into the snippet body.
  2. Insert the content from the first snippet into the second.
  3. Write/find a plugin to do it. I don't know of any off the top of my head though so I can't help with anything specific. If I think of any though, I'll update my answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM