Sublime Forum

Snippets have stopped working after upgrading to Sublime Text 4

#1

After upgrading to Sublime Text 4, the snippets that were previously working have stopped. Has anyone experienced the same and/or has a fix to get snippets working correctly again?

Here is an example snippet:

<snippet>
	<content><![CDATA[
foreach ( ${1:$key} as ${2:$value} ) : ?>
	${3}
<?php endforeach;
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>fore</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.php</scope>
</snippet> 

This was outputting a “foreach” block in ST3 and I was able to tab through and replace the values:

foreach ( $key as $value ) : ?>
	...
<?php endforeach;

but now the same tabTrigger of “fore” outputs only “foreach” and that’s it.

foreach

If I trigger the snippet using command-shift-p and searching for it, the snippet outputs more of the snippet, but the variables are still missing:

					foreach (  as  ) : ?>
						
					<?php endforeach;

Any help or guidance would be appreciated.

Thanks

1 Like

#2

Does that still appear that way if you switch your color scheme to one of the ones that ships with Sublime, such as the default?

0 Likes

#3

same! all of my snippets just stopped working after upgrading.

snippet:

<snippet>
	<content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>swifthi</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!--<scope>source.js</scope>-->
</snippet>

i changed the color scheme, it flashed the correct snippet ONCE and then it went back to not coming up in search results… please fix!

0 Likes

#4

After a fresh install snippets are working as expected. Just make a copy of ~/Users/{user}/Library/Application Support/Sublime Text 3/…

And then remove that folder, do a fresh install and copy over your snippets to the new Sublime folder that the new install creates @themascott

0 Likes

#5

Same issue here, they don’t show up on the ad-hoc suggestions list so I can’t trigger them with tab, but I can find and trigger them through the command palette. Switching to the standard theme didn’t help either.

I did reset the config and they showed up for some time. I started installing my usual packages and they kept working. Today I noticed they the snippet suggestions where gone again. I have a suspicion about the Naomi package, which I install recently and lastly, but deleting it did not bring snippet suggestions back.

Any help/tips is/are greatly appreciated.

1 Like

#6

Same problem here: Even setting

“auto_complete_include_snippets”: true,
“auto_complete_include_snippets_when_typing”: true,

in preferences doesn’t work! I’ve tried even everything suggested here, but without success! Hope somebody has a solution! Thanks!

1 Like

#7

Did anyone figure this out?

For me, snippets only work when a dropdown of autocomplete suggestions doesn’t show up. Snippets don’t show up in autocomplete dropdown, despite not having futzed with the default settings. Build 4113.

1 Like

#8

Does the same thing also happen in Safe Mode?

0 Likes

#9

I don’t use snippets often, but I would like to use them more often. I had created a bunch in ST3 and realized, since upgrading to ST4 that I couldn’t find them anymore. Like, the Snippets command palette was completely empty. When I was in Safe Mode, I had the one Lorem Ipsum snippet, but none others. I went through and manually disabled a bunch of my packages before it dawned on me that snippets are keyed to a particular syntax. When I started using ST4, I changed my syntax from Javascript to JSX. All of my snippets were created with the Javascript syntax, so that’s why none of them were showing up when I was in a file set to the JSX syntax.

How can I edit those existing snippets so I can change the scope to source.jsx?

0 Likes

#10

You can do that by editing the <scope> of each sublime-snippet. For example:

<scope>(source.js | source.jsx)</scope>
0 Likes