2

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.%"

1 Answer 1

3

Note: you have an excess (as I persume) </script> ending tag in HTML snippet.

What you have to do is this:

HTML

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

PHP

<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

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

1 Comment

Doesn't matter! Accepting is enough! Welcome to SO!

Your Answer

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