Sublime Forum

ST3: Edit pre-existing snippets?

#1

Hi!

I apologize if this has already been addressed, but I’d like to edit the existing snippets for PHP. Specifically, to change the bracket style to match the house-style my dev team uses (opening bracket on newline). This was fairly easy to do in ST2, but I can’t figure out how to do this in ST3, since there’s no clearly named PHP definition file in the Application Support/Sublime Text 3/ directory in OS-X.

Any help would be greatly appreciated.

Thanks (and I love the product)!

F

0 Likes

#2

Hello!

Snippets for languages are now contained in the app itself so if you head on over to

/Applications/Sublime Text.app/Contents/MacOS/Packages

you will see several files and the file you are looking for is “PHP.sublime-package”. sublime-packages are just zip files so what I tend to do is rename them with a .zip extension and double click to open and extract and the file you are looking for will be in there.

0 Likes

#3

Perfect, thanks!

F

0 Likes

#4

Finally had time to edit the snippets, but doing so caused problems.

For the record, I went into /Applications/Sublime Text.app/Contents/MacOS/Packages/, renamed the PHP package with a .zip extension, unpacked it, opened/edited the snippet files, then re-zipped the directory (using OS-X right-click->Compress), and renamed the zipfile, removing the .zip extension.

When I relaunched ST3, I got a ton of errors saying the language file could not be found, and the ApplySyntax package stopped working. Retried the procedure several times, and it never clicked.

Is there anything special I need to do re zip parameters, permissions, etc.? Seems like I must be missing a step.

0 Likes

#5

You shouldn’t have to package everything back up. In fact, that’s probably the wrong way to go about it since it’s possible for that to be overridden by future updates.

See Overriding Files From a Zipped Package at the following page. sublimetext.com/docs/3/packages.html

You may also want to take a look at PackageResourceViewer to help also.

0 Likes

#6

I realize I’m a year late, but this is what I did:

I wanted to change the function completion of get_defined_vars(), because it adds “oid” as argument, and I never want that.

  1. I copied and renamed PHP.sublime-package to zip and opened it
  2. Looked for get_defined_vars inside the files
  3. Found file PHP.sublime-completions
  4. Used PackageResourceViewer to edit that file
  5. Save file
  6. Delete that copied renamed ZIP file

PackageResourceViewer makes sure everything is saved correctly. My new fav package.

0 Likes

#7

Then “save as” and place in your Packages/User folder as to maintain your changes through any updates.

0 Likes