Skip to Content

Sublime Projects File Hack

On this project I’ve been working on there are several components which could really be broken up and managed as individual Sublime projects.

I like to be able to search across several of them at once though so I’ve gotten into the habit of simple calling them all within one project.

:::json
{
	"folders":
	[
		{
		"name": "Project1",
		"path": "/C/inetpub/wwwroot/project1",
		"file_exclude_patterns": ["*.sublime-workspace"]
		}
		,{
		"name": "Project2",
		"path": "/C/inetpub/wwwroot/project2",
		"file_exclude_patterns": ["*.sublime-workspace", "*.gitignore"]
		}
		,{
		"name": "Project3",
		"path": "/C/inetpub/wwwroot/project3",
		"file_exclude_patterns": ["*.js","*.css"]
		}
		,{
		"name": "Common",
		"path": "/C/inetpub/wwwroot/common/"
		}
	]
}

This works fine but at other times I don’t want to see all of them so I edit the project file to add or remove certain projects via commenting out code.

Being JSON however that damn comma always wreaks havoc when I save.

:::json
{
	"folders":
	[
		// {
		// "name": "Project1",
		// "path": "/C/inetpub/wwwroot/project1",
		// "file_exclude_patterns": ["*.sublime-workspace"]
		// }
		,{
		"name": "Project2",
		"path": "/C/inetpub/wwwroot/project2",
		"file_exclude_patterns": ["*.sublime-workspace", "*.gitignore"]
		}
		// ,{
		// "name": "Project3",
		// "path": "/C/inetpub/wwwroot/project2",
		// "file_exclude_patterns": ["*.js","*.css"]
		// }
		,{
		"name": "Common",
		"path": "/C/inetpub/wwwroot/common/"
		}
	]
}

To get around this I setup a bogus ‘project’ that points nowhere:

:::json
{
	"folders":
	[
		{ 
			// intentionally left blank 
		}
		// {
		// "name": "Project1",
		// "path": "/C/inetpub/wwwroot/project1",
		// "file_exclude_patterns": ["*.sublime-workspace"]
		// }
		,{
		"name": "Project2",
		"path": "/C/inetpub/wwwroot/project2",
		"file_exclude_patterns": ["*.sublime-workspace", "*.gitignore"]
		}
	]
}

Now I can easily comment or uncomment any of the projects below it without fear of forgetting to add, or remove a comma.