Sublime Forum

Edit settings to .sublime-project files

#1

In my .sublime-project file I can see there is a “settings” entry that was added by another package. Is it legal for the user to add entries to the .json or will ST overwrite them?

Something I miss about TextMate is that there appears to be no supported way to add arbitrary information into ST projects, even though there is json file that could be used. VSCode has a really nice built in editor to make this possible but I don’t see that ST supports this, at least not officially. I would expect a “Edit Project Settings” option in one of the menus.

Thanks.

======

{
	"folders":
	[
		{
			"path": "."
		}
	],
	"settings":
	{
		"LSP":
		{
			"phpls":
			{
				"enabled": true
			}
		}
	}
}
0 Likes

#2

Sublime rewrites the sublime-project file when you make changes to the folders that are contained in it (adding, removing, dragging to change the order, etc) or if a plugin modifies the project data.

When the rewrite happens any comments in the file will be removed, keys may be reordered and the indentation of items may change, but otherwise it leaves the data in the file alone. This is similar to what happens when the Preferences.sublime-settings is updated.

Having a settings key here is officially supported, as is putting whatever setting you want in it (including ones you make up yourself or ones that packages use). The project format mentions folders, settings and build_systems but as far as I’m aware there’s no issue with adding your own arbitrary keys to the file apart from that if you want to. I’m pretty sure I’ve come across packages that do that, though I can’t think of any offhand.

For example, you can create a new empty window, and in the Console of that window run something like:

window.set_project_data({"randomKey": True})

Once you do that, use Project > Save Project As... to save the project to disk followed by Project > Add folder to project... to add some folders. If you now use Project > Edit Project, you can see that the project file now contains not only the folders item but also the key that you added.

2 Likes

#3

I had no idea that was there! I don’t know how I missed this when I was first learning ST but I just assumed it didn’t exist. Thanks for writing out that detailed response, I really appreciate it.

1 Like