Projects In Sublime Text 2

In the past I've always been working on just one project so I have never explored 'projects' in Sublime Text 2.

Today I needed to work on multiple things so I broke down and discovered how projects work. Like everything else in Sublime they are very simple, and offer a lot of flexibility.

Step one is to create a new project. You do that by simply adding a folder.

Project > Add Folder to Project...

Your project files and folders should now be displayed in the sidebar.

Now save your project.

Project > Save Project As...

This will create two files:

  1. your_project.sublime-project
  2. your_project.sublime-workspace

From the Sublime Text 2 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.

The sublime-project file allows you to make project specific configurations to Sublime. You define multiple folder paths as well as specify folders and files you want to exclude from view. You can also define per project Settings for Sublime:

{
    "folders":
    [
        {
            "path": "wwwroot",
            "folder_exclude_patterns": ["images"]
        },
        {
            "path": "c:\wwwroot\project1\assets",
            "name": "Project 1",
            "file_exclude_patterns": ["*.php"]
        }
    ],
    "settings":
    {
        "tab_size": 8
    }
 }

Here we're defining two folders. The 'name' attribute will define the name that is displayed in the Sublime sidebar for this folder. This is helpful if you have a long path or folder name and want a more descriptive label.

Once you have multiple projects setup, you can easily switch between them by hitting CTRL+ALT+P. That will bring up a dialog of all defined projects. You can either click on the project or start typing a project name to apply a filter.

I'm still learning how best to use projects but I like the flexibility of defining multiple folders and being able to specify the path. I'm working on a project now with many deeply nested subfolders and can simply map to a specific directory instead of having to click down through several folders.

Go Top
comments powered by Disqus