10

I have several files that I edit frequently, and I need all of them open at the same time. I am wondering if there is a way in sublime to save a set of files to be open...sort of like how in chrome or firefox I can have a set of web page tabs that I can configured to be open with the click of one button

Kyle
  • 203

3 Answers3

7

It won't be like firefox/chrome. What I have seen, Sublime can open your tabs from last time, but it can't open a certain set of tabs automatically.

Open project, open the files you want open next time. Important - When closing Sublime, first choose Project > Close Project, then close Sublime. That will save the open tabs.

Then open each project as thisguy123 describes. Or use the command line option --project path/to/project.sublime-project.


It is annoying to close each project like this every time so set up a keyboard shortcut:

Save file as ".../Packages/CloseProjectAndExit/close_project_and_exit.py". If you don't know where your Sublime Packages directory is, look at this: http://docs.sublimetext.info/en/sublime-text-3/basic_concepts.html#the-data-directory .

import sublime
import sublime_plugin


class CloseProjectAndExitCommand(sublime_plugin.WindowCommand):
    def run(self):
        self.window.run_command("close_project")
        self.window.run_command("close_window")

Copy to keymap:

{ "keys": ["ctrl+shift+`"], "command": "close_project_and_exit" }
d_rail
  • 2,989
4

Save it as a project. Project-> Save Project As...

Then when you want to open the tabs again, just go to Project -> Open Project

2

In ST3 Switch Project should replace the current set of tabs with what you last had open on that project.

If it doesn't, that means something is wrong with the project's default workspace.

(solution further down)

Explanation

Sometimes the workspace file gets deleted or something got muddled up, perhaps during directory moves, or issues with files being .gitignored in one branch but not another etc...

From documentation

Projects in Sublime Text 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.

Another possibility is that you saved a project to a workspace file or vice versa. I think the reason this happens is because it's easy to confuse the two, because when you do Quick Switch Project it shows you both sublime-project files and sublime-workspace files.

Note: The reason it does that is because you're allowed multiple workspaces per project. In Quick Switch Project if you select a workspace, it opens that workspace's project and activates that workspace; if you select a project, it opens that project and activates the project's default workspace, unless it cant find it, in which case it does nothing.

Solution

First do a Save Project As to:

my-project-name.sublime-project

That's just a safety/sanity step. Then Save Workspace As to:

my-project-name.sublime-workspace

Where the file names match. The project will now remember the set of tabs, and switching to will open them.

AndyHasIt
  • 131