Sublime Forum

Cannot edit the foreach snippet in PHP

#1

I’m trying to edit the foreach snippet of PHP with this method.

The original one is:

<snippet>
	<content><![CDATA[<?${TM_PHP_OPEN_TAG:php} foreach (\$${1:variable} as \$${2:key}${3: => \$${4:value}}): ?>
	${0}
<?${TM_PHP_OPEN_TAG:php} endforeach ?>]]></content>
	<tabTrigger>foreach</tabTrigger>
	<scope>embedding.php text.html - source.php</scope>
	<description>&lt;?php foreach (…) … &lt;?php endforeach ?&gt;</description>
</snippet>

I wanna change it to:

<snippet>
	<content><![CDATA[
foreach ( \$$1 as \$$2 ) {
	$0
}
	]]></content>
	<tabTrigger>foreach</tabTrigger>
	<scope>embedding.php text.html - source.php</scope>
	<description>foreach ( $... as $... ) { ... }</description>
</snippet>

But the default one is still there and nothing is changed. So far this only happens on this specific snippet, is this a bug or am I missing something or I was doing something wrong here?

0 Likes

#2

Do you see your changed version and also the original? In order to be an override, the full name and path of the file needs to be identical between the installed package and your override. In the case of snippets in the PHP package, the packaged version is in a subfolder inside the package named Snippets, so your local file should be named Packages/PHP/Snippets/namehere.

Note that there are also two default snippets in the PHP package with the same tab trigger, which may also cause some confusion.

0 Likes