Sublime Forum

Replacing a snippet

#1

Hi,

I’d like to replace the default JavaScript snippet function.sublime-snippet.

Is this possible without touching the file in the JavaScript package? E.g. can I somehow add a file to my User package that overwrites the JavaScript snippet? Just copying function.sublime-snippet to my User package and changing it did not work.

Thanks,
Martin

0 Likes

#2

It’s not possible, the only option is to edit the original snippet.

0 Likes

#3

I’ve just encountered this situation myself. I expected a snippet using the same tab trigger for the same scope to replace one defined earlier, but that is not the case. Both snippets showed up and if the description is the same, there is no way to tell them apart. It does appear that they are listed in the order they are created, so a later one will be lower than an earlier one.

I can see why just blindly replacing snippets on tab trigger would not be a good idea, but what are the ramifications of replacing based on tab trigger and scope? Is it reasonable to have multiple snippets for the same scope using the same tab trigger? Maybe an option (defaulted off) in the settings to allow override/replacing? I’m getting more and more leary of editing/changing anything that isn’t mine, so I’d rather not go into packages and start editing things.

0 Likes

#4

I believe the order of the snippets changes with usage, but it’s not something that can be relied upon.

I just copied/movied all the snippets I didn’t want outside of the Packages folder. They would probably be re-instated on a future build, or I could just move them back if I wanted to.

Alternatively, why not give your snippet-version a slightly different trigger?

0 Likes

#5

Hm. Hadn’t thought of that. That very well may be.

I considered something to this effect, but I loathe getting into a process that requires me to check/move/update things after updates, especially considering that packages installed via Package Manager update silently. When things suddenly stop working the way I expect them to, I get a little frustrated.

Muscle memory :smile: This is actually what I wound up doing. Old dogs can be taught new tricks, it just takes longer and they oftentimes don’t ever get them down just right.

0 Likes