Reputation:
PHP:
<snippet>
<content><![CDATA[
foreach (\$${1} as \$${2:k}=>\$${3:v}) {
${4}
}
]]></content>
<tabTrigger>fore</tabTrigger>
<scope>source.php</scope>
</snippet>
HTML (and on .php files with html)
<snippet>
<content><![CDATA[
<?php foreach (\$${1} as \$${2:k}=>\$${3:v}) : ?>
${4}
<?php endforeach; ?>
</script>
]]></content>
<tabTrigger>fore</tabTrigger>
<scope>source.html, text.html.basic</scope>
</snippet>
how can I enable "text.html.basic" on the second snippet without making it trigger when I'm on a PHP file, since it's also "text.html.basic source.php.%"
Upvotes: 2
Views: 937
Reputation: 12197
Note: you have an excess (as I persume) </script>
ending tag in HTML snippet.
What you have to do is this:
<snippet>
<content><![CDATA[
<?php foreach (\$${1} as \$${2:k}=>\$${3:v}) : ?>
${4}
<?php endforeach; ?>
]]></content>
<tabTrigger>fore</tabTrigger>
<scope>text.html - source.php</scope>
</snippet>
<snippet>
<content><![CDATA[
foreach (\$${1} as \$${2:k}=>\$${3:v}) {
${4}
}
]]></content>
<tabTrigger>fore</tabTrigger>
<scope>source.php</scope>
</snippet>
As you may see, the HTML snippet negates the source.php
scope with a -
(minus) sign
Upvotes: 3