58

If I open ~/foo.txt then open ~/baz/bar.txt from Terminal, Sublime Text always opens 2 different windows. It's aggravating to have all these different windows open..

I've tried changing a bunch of ST's settings, but nothing seems to fix this.

Is there a way to have ALL files and folders just open up in the same window as if I were manually adding all these folders to the project?

10 Answers 10

110

In Sublime Text Menu:

Preferences ->  Settings - User

Look for 'open_files_in_new_window'

And change 'true' with 'false'

Sign up to request clarification or add additional context in comments.

7 Comments

I thought that was the answer and that was one of the many settings I changed, but it didn't seem to help. Thanks though.
oh, I'm sorry, I just test it now, reboot my sublime, and it works for me :( ....
I can also confirm that it works. Running ST3 on OS X. However, instead of changing the value in the default settings file it is better to copy the setting to the user settings file and change the value there. That way you keep your settings if the default ones are overwritten.
Eh. If it works for you guys that's good enough for a Answer check from me.
But I guess this open_files_in_new_window is OS specific and it's only for OSX or at least that's what Default settings claims // OS X only: When files are opened from finder, or by dragging onto the // dock icon, this controls if a new window is created or not.
|
25

Rather than editing the SublimeText default settings (as Jahnux73 suggested), you should go to Preferences -> Settings - User, and add the following:

"open_files_in_new_window": false,

The SublimeText default settings file should not be modified, as it may be overwritten by Sublime updates, and so that you'll always be able to restore the default settings. The way Sublime works is that at runtime, it reads and applies the default settings, and then reads and applies the Settings - User file. In the event of a conflict, the User settings take precedence. That way, you can add your own settings without modifying the default configs.

5 Comments

Yeah, sorry, I should've mentioned this on his answer, but yeah, I know how to set the settings safely. =)
@CorySimmons: Okay, just wanted to make sure you weren't messing up your Sublime install. :)
actually, on Sublime Text 3 the default settings are read-only, so you can't accidentally mess them up like you could in Sublime 2.
@MattDMo: oh, yeah, I didn't notice he had tagged his post as sublimetext3.
Ugggh, this only works when opening files from Finder or other system stuff, not the built-in subl console command. 🤦🏻‍♂️
16

Folder can be directly dragged to sidebar, or from menu bar select

  • Project --> Add Folder to Project.

And better, since this has the same functionality as File -> Open folder which isn't mapped to a shortcut by default. You can make this a key mapping by going to

File -> Preferences -> Key bindings and append

{ "keys": ["ctrl+shift+o"], "command": "prompt_add_folder" },

then you can use CTRL+SHIFT+O to add a folder.

3 Comments

"open_files_in_new_window": false, didnt work for me. So this answer was golden!
tks, this is what i want, hell yeah
this is the right way to do it. I don't want to open all projects in the same window.
11

For mac OS two changes are needed

1- Preferences -> Settings - User

Look for 'open_files_in_new_window'

And change 'true' with 'false'

2-

In system Preferences find the Dock and then change its setting for the option “Prefer tabs when opening documents” and choose Always.

Then do :

subl folder_1

subl folder_2

subl folder_3

I explained in details here

enter image description here

New MacOS versions

4 Comments

I don't see that parameter with Monterey version.
@ymoreau I updated my article here: panjeh.medium.com/… and also edited my post in stackoverflow
This worked for me. Remember to quit sublime text and reopen it.
@corysimmons This should be the accepted version for newer versions of MacOS. Works like a charm.
9

Drag files or directories to sublime window will add them to current window instead of opening new one.

Comments

3

All the answers above indicate the parameter files only, but this does not work for folders. I found this solution:

  1. You need to go to the registry path HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command
  2. Change command add the parameter -a, get: C:\Program Files\Sublime Text\sublime_text.exe "%1" -a

  • Also, if You have a custom alias for the console, you can use it like this: subl . -a

Comments

1

All those replies above didn't work. Here I found the real solution to this problem: -

Click Preferences

 > Settings - Distraction Free

Then add these lines in user panel:
"open_files_in_new_window": false,

And click Save.

Here you go!!

1 Comment

Works on MacOS Ventura
0

None of the answers above worked for me.

I had a Sublime app icon pinned to the Dock and every time I opened a new file through the Finder context menu (Open With > Sublime Text.app) it went to a newly opened instance of Sublime that's displayed in "recent apps" zone of the Dock. So I always had 2 icons in the Dock, each with different set of tabs.

I simply removed the first icon from the Dock, and pinned the one from "recent apps" area, and dragged it to the place where the first icon used to be.

This seems to work fine provided that you set "open_files_in_new_window" to "false" (Preferences > Settings), as suggested in other answers.

Comments

0

I think the accepted answer is not good enough for currently new version because I followed it but failed. So I here posted my going.

There are two items in settings to focus: open_files_in_new_window and native_tabs.

The first one can be kept as default value never ( but it may impact nothing on MacOS whereas I didn't test it );

While the second one MUST have to be updated to preferred, whose original value is system.

After this, you'd better restart Sublime software.

Comments

0

For mac users(macOS tabs in 10.12 and newer), you need set "native_tabs" to "preferred".Sublime Text opens a new window, but the OS organizes them in native tabs.

The following response might be helpful to you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.