Sublime Forum

Edit default snippet on ST4

#1

Hello, is it possible to edit the default snippet without PackageResourceViewer? Or replace also can…

0 Likes

#2

PackageResourceViewer (or even better, OverrideAudit, which doesn’t have the options that PRV does that allow you to disastrously affect your Sublime install by accident) are the best ways to edit a snippet, but you don’t need them.

Use View Package File from the command palette to open the snippet, then Preferences: Browse Packages to open the Packages folder; create a folder in there that matches the folder(s) that the snippet you opened are inside of, then save the snippet, close it and re-open it.

Using OverrideAudit, you can use it’s Create Override command, or use View Package File to open any resource, and then choose Override This Resource from the command palette or context menu and just edit and save.

0 Likes

#3

Hello, I can see the path is PHP/Snippets/php-if-(___)-___-php-endif.sublime-snippet.

May I know what should be the folder name? Should it be PHP or Snippets? Or I create both of them?

save the snippet

Do I edit the original file or do I create a new one inside of the folder that is newly created?

Or do you mean when I create a new folder inside the Packages folder, there would be a new file automatically after I save the original file, then I only edit the new file that is in the new folder?

0 Likes

#4

It should be both; you need a folder named Packages/PHP/Snippets and inside of it a file with the name that represents the snippet (this applies to all packaged files of all types not just snippets, but that’s the example that we’re using here).

When you use View Package File to open the file, the buffer will be read-only because when it opens the file the file is contained inside of a sublime-package and is uneditable; so after you save you need to close the buffer and then open the file again, and that time the file will be on disk and thus editable.

Once you do that, you can edit it however you would like. Any changes you make will be immediately recognized (i.e. you don’t need to quit Sublime or anything).

All of these steps are what PRV and OA are doing for you so that you don’t have to do them all yourself; in addition OA also has the ability to show you how your file is different from the one that’s prepackaged, and warns you if it ever gets updated in case you want to incorporate changes.

0 Likes

#5

Hmm, do you mean to use View Package File to open the file -> save -> close? And then I use View Package File to open the file again, then this time I can edit it?

If so, why do I need to create a new folder inside the Packages folder?

0 Likes

#6

That is correct, yes.

Technically speaking, you don’t HAVE to create the folder, but since the file expects to live in Packages/PHP/Snippets in your case, and there will be no PHP folder unless you create one, when you press save you’re going to get an error because it can’t put the file where you need it to be.

0 Likes