By josh / June 6, 2014

Where should you keep your Sublime Text projects?

Reader Matt S. wrote me recently because he’s been procrastinating on migrating to a new computer, partly because he isn’t sure how best to transfer his Sublime Text preferences and plugins.

This also got him wondering about where he should be keeping his Sublime project files:

I tend to keep .sublime-project/.sublime-workspace files close (in the file system) to the project they pertain to… this might be ill-advised? I don’t know, maybe better to keep them all in a single directory? ~/.sublime-projects??

Do folks keep them in the project’s source repo? I haven’t actually done that… not sure how I feel about it.

When I first started using Sublime projects, I didn’t like the idea of keeping them in the project root directory either. Wouldn’t it be better to keep all of my projects in a single folder? Then I could easily open any project from a central location.

It turned into a bit of a mess, especially because I was syncing between multiple machines. Adding folders to the projects became a pain, because I’d have to stop and figure out an appropriate relative path…

Sublime projects are really meant to be housed alongside the project’s code files. Says the official Sublime documentation:

Projects in Sublime Text 2 are made up of two files: the sublime-project file, which contains the project definition, and the sublime-workspace file, which contains user specific data, such as the open files and the modifications to each.

As a general rule, the sublime-project file would be checked into version control, while the sublime-workspace file would not.

For multi-developer projects, this makes it easier to get the code building on your machine–project files can include special build tasks. You can also include project-specific preferences, like using two spaces for indentation instead of four.

Life got easier when I quit trying to fight The Man and use projects as they were intended to be used.

For more about how to use Sublime projects, go here:

http://sublimetexttips.com/newsletter

About the author

josh

1 comment
Tommy - February 5, 2016

I’ve wanted to keep .sublime-project files in the repo, but whenever I checked existing files stored outside the repo, the paths were always absolute (which makes them useless on any other computer).

I just created a new .sublime-project file in the repo, added folders, and checked it; Lo and behold, the paths are relative! The .sublime-project file just has to be at or above the directories you want added to the project in order for the paths to be relative. Cool!

Reply
Click here to add a comment

Leave a comment: