PHP:
<snippet>
<content><![CDATA[
foreach (\$${1} as \$${2:k}=>\$${3:v}) {
${4}
}
]]></content>
<tabTrigger>fore</tabTrigger>
<scope>source.php</scope>
</snippet>
HTML(以及带有html的.php文件)
<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>
如何在第二个代码段上启用“ text.html.basic ”而不会在我使用PHP文件时触发它,因为它也是“ text.html.basic source.php。%“
答案 0 :(得分:3)
注意:您在HTML代码段中有一个多余的(我已经过时)</script>
结束标记。
你需要做的是:
<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>
正如您所看到的,HTML代码段取消source.php
范围与-
(减号)