Sublime Forum

Trying to understand project system vs. plain files

#1

I have created a few projects in ST2 as it is a quick and convenient way to go back and forth between multiple sets of files. However, I also tend to do right-click, Open in Sublime Text quite often in Windows Explorer, i.e. I frequently use ST2 to edit random files on my filesystem.

When I do “Open in ST2” from explorer, it will open that file in whatever project I’ve got currently open. When I do that multiple times, various files from all around my PC end up as tabs in one of my projects and it doesn’t feel good.

Is there a way to configure ST2 to open random files in a new instance / window or automatically create a “stale project” for them? Like that I could switch (Ctrl+Alt+P) from “no project” to some of my projects and then just choose “close project” and be right back in the window with my random files? (Currently, closing the project will show just an empty ST2 window, all files opened independently of any project will not be restored.)

Thanks.

0 Likes

#2

I’d like that too. This is how TextMate on OSX works - whether you tell it to open a file or directory it spawns a new window, then if you tell it to open a directory it displays the directory as a project.

0 Likes

#3

You can edit the registry key for Open in Sublime and add --new-window as a command line argument.

0 Likes

#4

Interesting. However, that will create a new window for every file, won’t it? It would be better if ST2 grouped non-project files into one instance of ST2, creating an “unnamed project” which would still act as a standard project.

0 Likes

#5

I think the easiest thing to do would be to drag the tab of the unrelated file onto the desktop, creating a new window. Then save this as a project called “general” or whatever, and drag other unrelated files there.

With several project windows open, opening a file via right-click from Explorer will open it in the most recently used window. If that wasn’t your “general” project, open it with Project, Recent projects, then drag the tab to that window.

Then you could add the “–project” parameter to the Open With context menu entry and specify the full path to the “general” project.

This creates an “Open with Sublime” in the right-click menu for every file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime]

[HKEY_CLASSES_ROOT\*\shell\Open with Sublime\command]
@="d:\\SublimeText2\\sublime_text.exe \"%1\" --project d:\\test\\general.sublime-project"

Then add context menu entries for opening in the current project or window (exclude the project parameter) or opening it in a new window (include that parameter). The next step would be to create a sub menu for Sublime Text like 7-Zip does, but I think that involves a shell extension dll, so I will leave that for later.

0 Likes

#6

I found in testing this that when a project is already open, trying to open another file into that project will cause it to open in a new window instead, which seems like a bug to me.

0 Likes

#7

Can confirm the same problem here. Opening new files into an already opened project doesn’t work.

0 Likes