Sublime Forum

Override skeleton for new_snippet?

#1

hello, there.

I want to change the default skeleton code when creating a new snippet. What is the best way to do it?

I can create a user snippet for snippets, but it has 2 drawbacks:

  • I have to manually set save location when saving
  • I have to manually set file extension when saving

thank you for any advice.

0 Likes

#2

sublimetext is only showing the first CDATA packet.

why is this not working?

<snippet>
	<content><![CDATA[Certain tokens like ]]]]><![CDATA[> can be difficult and <valid>]]></content>
</snippet>

this results in

Certain tokens like ]]

instead of

Certain tokens like ]]> can be difficult and <valid>

0 Likes

#3

because ST is likely using a custom XML parser for snippets and just ignores everything after the end of the first CDATA.
You can use https://packagecontrol.io/packages/PackageResourceViewer to open the Packages/Default/new_templates.py file and edit the new snippet template there.
Don’t forget to also install https://packagecontrol.io/packages/OverrideAudit to know when your customizations are out of date

0 Likes

#4

that’s it, thank you!

shouldn’t I save it to my ‘Packages/User’ directory, though?

0 Likes

#5

If you save the modified file in your User folder, there will be multiple plugin files in multiple packages that define the same commands. Technically that should work OK I think because User is loaded last and “wins”, but depending on how you look at it, it may or may not seem cleaner to do that way.

1 Like