Sublime Forum

The correct way to use built in snippets?

#1

Hey,
So i love being able to TAB a trigger (for instance html:TAB, h1:TAB, li:TAB etc) to expand the html.

However, if I’m in a PHP doc, this functionality rarely ever triggers, yet I watch other videos, and sometimes at random for myself it will trigger and work correctly.

I even use Shft+Ctrl+P: Syntax html (in the php document) to try and force a syntax change (in the hope that triggers will change) but it just keeps the syntax as PHP.

Is there a way to globally allow default tab triggers? I’ve found that if there’s been an overlap (multiple triggers registered) it will just show a dropdown to choose the correct one.

Obviusly if i need to add any html elemtent to any document that isn’t an HTML doc, i then have to add it all manually. I’m still learning ST2’s ins and outs, but this is my biggest gripe, and If someone can set me on the right path here I’ll be a very happy man.

0 Likes

#2

Save your file with a .php extension, use Shift+Ctrl+P, and type “snippet” to see which snippets are available. If you’d like more, you can add a third-party library, like “sublime-phpsnippets.”

If you haven’t installed package control, you might want to do that first:
wbond.net/sublime_packages/package_control

Based on your question, you might find this free & excellent tutorial series useful:
tutsplus.com/course/improve-wor … me-text-2/

0 Likes

#3

[quote=“britalb”]Save your file with a .php extension, use Shift+Ctrl+P, and type “snippet” to see which snippets are available. If you’d like more, you can add a third-party library, like “sublime-phpsnippets.”

If you haven’t installed package control, you might want to do that first:
wbond.net/sublime_packages/package_control

Based on your question, you might find this free & excellent tutorial series useful:
tutsplus.com/course/improve-wor … me-text-2/[/quote]

Thanks for the reply :smiley:

I’ve worked my way through Jeff’s ST2 course, and have package control installed; installing additional snippets seemed to have helped, though my main issue was simply accessing other language snippets (for instance html snippets) from within a php document, and when ‘trying’ to change the syntax (wouldn’t switch, i assume due to the file name being .php, which is a shame and seemingly a lack of control) it would still fail.

I followed your recommendation, but installed HTML snippets instead and that seems to have allowed me to run html snippets in .php documents again (though i could initially do this by default without plugins, so I’m quite incertain why there are inconsistencies). Anyway, from here I imagine I just have to make my own snippets or install additional ones.

0 Likes