Hoseong Jeon
Hoseong Jeon

Reputation: 1350

How to open ~~~.sublime-package file?

I'm using Sublime Text 3 and I can't open ~~~.sublime-package files.

When I open it with Sublime Text 3, it looks like this:

504b 0304 1400 0000 0800 9496 084d 8c0b
5989 b600 0000 0501 0000 0a00 0000 2e67
6974 6967 6e6f 7265 358e c16a 0331 0c44
effa 0a43 6f81 557f 2297 420a 8524 a752
8a62 2bae a9d7 32b2 b224 7f1f 3b9b 5c84
f466 18cd 06eb eddb cb0f 6cd0 e61d 9578

The file is longer than that of course, but anyway, I can't read it.

How can I read and edit this file?

Upvotes: 2

Views: 5832

Answers (2)

OdatNurd
OdatNurd

Reputation: 22791

A sublime-package file is just zip file with the extension changed; i.e. if you have a tool that can open a zip file, you can open the package and review the contents using it. This may or may not require you to temporarily rename the file to have zip extension, depending on the tool.

That said, modifying a sublime-package directly is only recommended and safe when you're the one that created the file in the first place; otherwise you run a risk of your changes getting lost when you least expect it.

To explain why, a little background. To begin with, there are two places where a sublime-package file can exist.

The first is in a folder named Packages that's inside of the installation folder for Sublime itself (i.e. where the executable is). These are referred to as Shipped packages because they ship with Sublime and are accessible to everyone using Sublime.

The second is in a folder named Installed Packages which is contained in your user specific Sublime Data folder. This location varies by platform but you can always find it by selecting Preferences > Browse Packages and then going up one folder level. Packages here are referred to as Installed packages and are packages that you yourself installed in Sublime. Generally speaking packages here are installed by Package Control.

When Sublime Text is updated to a new build, it replaces all of the Shipped packages with (potentially) entirely new sublime-package files in order to update them.

Similarly, when Package Control upgrades a package, it throws away the old sublime-package file and replaces it with a newer version.

This all boils down to the following: Never directly modify a sublime-package file that you yourself didn't personally copy into the appropriate location, or at some point in the future your changes will be unceremoniously wiped away during a package upgrade.

So that leaves the question of how to actually modify a package file when you need to, and the answer is to create an Override.

There is a folder called the Packages folder which you can get to by selecting Preferences > Browse Packages from the menu. This folder can also contain packages, but here they are Unpacked; that is instead of having a file named MyPackage.sublime-package that contains some files, there would instead be a folder named MyPackage that contains files.

As Sublime is going through a sublime-package file loading up the files that it contains, it looks in the Packages folder to see if there is a folder there with the same name as the sublime-package file; if there is, and there is a file inside of that folder that has the exact name and path of the file from the sublime-package, Sublime will load it instead of the one from the sublime-package file.

For example; assume there is a package named Foo.sublime-package that contains a file called foo.py; as Sublime is scanning through Foo.sublime-package for files it should load, it notices that there is a foo.py file. So it checks to see if the file Packages/Foo/foo.py exists, and if it does, it loads that file and ignores whatever was inside of the sublime-package file.

The contents of the Packages folder is not touched during upgrades of packages that are stored as sublime-package files, so this means that if you create an Override in this manner, your change will persist even if the underlying package upgrades.

The easiest way to create such an Override is to use PackageResourceViewer. With this package installed, you can use PackageResourceViewer: Open Resource from the command palette to easily open any file from any package, and saving the file will make PackageResourceViewer automatically create the override for you.

With all of this said, an important caveat; whereas modifying a sublime-package directly will cause your changes to be unceremoniously thrown away without any warning, creating an override will cause Sublime to always use it even if the package is modified.

Depending on the file and the modification, this can be important. In the example above, if you created an override on foo.py to change something about it and then the author of the Foo package made changes to foo.py to fix a bug or add more features, when the package updates your changes aren't lost but they also will stop the changes in the update from taking effect.

The OverrideAudit package can help here; one of the things it does it check on upgrades to see if you have an override of a file in a package that was upgraded and warn you so that you can check and see what's going on.

Upvotes: 17

The Des
The Des

Reputation: 41

The file you are trying to open is basically an archived package or a zip file (just not with the usual naming convention)

You may need to extract the zip or store it in the correct location so that Sublime Text Application can use them.

https://www.sublimetext.com/docs/3/packages.html

Upvotes: 2

Related Questions