When you first start using Sublime Text, the way in which projects work may not immediately make sense. What is a project? Wait, I have to save a file? Where do I save the file? I’ll cover the basics below, to get to you started.
So what do I need to know?
You Are Always in a Project
Every time you have something open in SublimeText, you are working in a new project. Until you save the project, there’s no record of your current setup (besides the default option “remember_open_files” which makes the application start up with the last set of open files).
The folders displayed on the program’s left sidebar are contained within the project; this isn’t necessary just a tree list. You can remove or add folders and files from other locations.
Projects Must be Saved, as a File
The configuration for your project is saved as the file type “.sublime-project”. To save, simply:
- Click the “Project” item on the menu (Sublime Text 2)
- Click “Save Project As”
- Choose a folder to save your project in. You may want to save all of these files in a single folder*.
- Name your project. This exact file name will show up when choosing from existing projects, so I’d use something readable.
- Save & Done.
*Where do I save my projects?
You could either save the sublime-project file in the same folder as the project you’re working on, or in one folder that contains all of your project definition files. Or somewhere else entirely. I prefer keeping them in one single folder, since I’d rather have my project directory only contain files that will be uploaded to the server (mirroring its contents), and because I can see and open all projects from one location.
Opening and Working with Previous Projects
You can go to Project->Recent Projects in the Sublime Text window, but an even quicker and more visual way is to use the shortcut that opens the switch project dialog:
- Windows & Linux: Ctrl+Alt+P
- Mac: Command + Ctrl + P
Alternatively, you can browse your computer to find the project file, right click and “Open in Sublime Text”. This will load up your project folder.
Note: If you are Moving Your Project Files (or Renaming the Folder they are in)
In my case, I wanted to rename the folder that stores my project files, but when I did, switching to existing projects no longer worked because Sublime Text 2 was looking in the wrong location. If you also run into this, there is a settings file that you can edit to change the directories in one fell swoop. The file is located here:
- WINDOWS x64:
C:/Users[Username]/AppData/Roaming/Sublime Text 2/Settings/Session.sublime_session
- MAC:
~/Library/Application Support/Sublime Text 2/Settings/Session.sublime_session"
Find the section called recent_workspaces
(should be at the very bottom), and you can edit the paths there.
Advanced Settings
Similar to editing the program’s user preferences, the project files are saved in the JSON format. This file gives you the option to set exclude patterns for file types and folders within your project. You can also override your user settings. Check out the first two links in the reference section for more info on editing these settings.
A Sidenote on SublimeText as an Alternative to Dreamweaver or Coda
Until SublimeText came along, it seemed like only Macs had the slickest web code editors around. If you’re still using Dreamweaver on Windows, it may be time to ditch that unstable beast. Using projects in SublimeText replaces DW’s Site Manager. If you’re editing hundreds of different sites, then you simply want to load one up from a list. Using the FTP extension, you can map a local folder to a remote folder, and you can edit remote files. If you’re accustomed to DreamWeaver’s Ctrl-Shift-U to upload files, the new shortcut to learn (for the extension) is Ctrl+Alt+U+F.
More Info and Reference:
Your section on moving project files was really helpful. Thanks.
Thanks, man. Super useful to get a quick rundown.
Thank you! I get it now 🙂
Thanks for this quick write-up. Something I found interesting after saving my first project was that the *.sublime-project file was empty (aside from a couple curly braces), which I did not expect, and it is the *.sublime-workspace file that has the meat of the pertinent info. The official documentation didn’t mention that and seemed to indicate the opposite.
http://www.sublimetext.com/docs/2/projects.html
In Sublime Text 3, the file Session.sublime_session has been moved to:
~/Library/Application Support/Sublime Text 3/Local/
This should be in the official docs! Thanks for writing it up.
Very helpful post. The “*Where do I save my projects?” part is a little confusing and could use some clarification:
“You could either save the project in the same folder as your project files, or in one folder that contains all of your project files.”
The term “project files” is confusing because it sounds like you’re referring to the same folder in both cases. I think a different term such as “project definition files” for the latter would be clearer.
Thanks for the suggestion. I’ve clarified that part.
On Ubuntu 16.04 the file Session.sublime_session is located here:
/home//.config/sublime-text-3/Local
Sorry, I put username inside chevrons so it got stripped out. the path should be /home/username/.config/sublime-text-3/Local
with your username instead. cheers, Dorothy
I keep everything in one place and it is really annoying having to navigate to my projects folder every time I need to switch projects. Is there a setting in sublimetext for that? like a “default_projects_folder” or something that automatically opens in the filemanager when we want to switch?
@Adinan I have the same issue / complaint.
I saved some projects in a single folder. After restarting the sublime the “switch project List” is empty. And always I have to open a project and load it.