51

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?

Qwerty
  • 29,062
  • 22
  • 108
  • 136
corysimmons
  • 7,296
  • 4
  • 57
  • 65

8 Answers8

107

In Sublime Text Menu:

Preferences ->  Settings - User

Look for 'open_files_in_new_window'

And change 'true' with 'false'

BENARD Patrick
  • 30,363
  • 16
  • 99
  • 105
  • 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. – corysimmons Jan 09 '14 at 14:59
  • 1
    oh, I'm sorry, I just test it now, reboot my sublime, and it works for me :( .... – BENARD Patrick Jan 09 '14 at 15:01
  • 1
    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. – Henrik Söderlund Jan 09 '14 at 16:14
  • 1
    Eh. If it works for you guys that's good enough for a Answer check from me. – corysimmons Jan 09 '14 at 19:17
  • 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.` – Abu Shumon Feb 06 '18 at 08:39
  • Doesn't work for folders for me. (Using Windows 7.) – Argyll Jul 21 '19 at 02:33
  • @Argyll This setting only works for macOS – Qwerty Feb 03 '21 at 12:57
23

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.

Eliza Weisman
  • 823
  • 9
  • 17
14

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.

Mark
  • 1,337
  • 23
  • 34
Abu Shumon
  • 1,834
  • 22
  • 36
9

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

Tofeeq
  • 2,523
  • 1
  • 23
  • 20
5

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

panjeh
  • 1,310
  • 1
  • 14
  • 11
  • I don't see that parameter with Monterey version. – ymoreau May 13 '22 at 10:09
  • 1
    @ymoreau I updated my article here: https://panjeh.medium.com/open-files-projects-folders-in-sublime-text-3-in-a-new-super-tab-in-the-same-window-on-mac-os-5d44254927eb and also edited my post in stackoverflow – panjeh May 16 '22 at 20:43
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
Артём
  • 31
  • 3
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!!

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.