How to Open files and folders in same window in Sublime Text on macOS?
Solution 1
In Sublime Text Menu:
Preferences -> Settings - User
Look for 'open_files_in_new_window
'
And change 'true'
with 'false
'
Solution 2
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.
Solution 3
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.
Solution 4
Drag files or directories to sublime window will add them to current window instead of opening new one.
Solution 5
All the answers above indicate the parameter files only, but this does not work for folders. I found this solution:
- You need to go to the registry path
HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3\command
- 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
Related videos on Youtube
![corysimmons](https://i.stack.imgur.com/1ZVkL.png?s=256&g=1)
corysimmons
I'm a fullstack web-developer currently specializing in React, React Native, Node, and Typescript. I have over 20 years of experience making websites (really, I can pull up my FF7 website from 1997) and over a decade of professional experience. My open source libraries have thousands of Github Stars and have been downloaded millions of times. I've written for just about every big publisher in the industry (Envato, CSS Tricks, a book for Packt Publishing, .net Magazine, etc.) and spoken at a few frontend conferences. Check out my website at corysimmons.com and feel free to reach out to me on there.
Updated on February 04, 2021Comments
-
corysimmons over 3 years
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?
-
corysimmons over 10 yearsI thought that was the answer and that was one of the many settings I changed, but it didn't seem to help. Thanks though.
-
BENARD Patrick over 10 yearsoh, I'm sorry, I just test it now, reboot my sublime, and it works for me :( ....
-
Henrik Söderlund over 10 yearsI 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.
-
corysimmons over 10 yearsYeah, sorry, I should've mentioned this on his answer, but yeah, I know how to set the settings safely. =)
-
corysimmons over 10 yearsEh. If it works for you guys that's good enough for a Answer check from me.
-
Eliza Weisman over 10 years@CorySimmons: Okay, just wanted to make sure you weren't messing up your Sublime install. :)
-
MattDMo over 10 yearsactually, on Sublime Text 3 the default settings are read-only, so you can't accidentally mess them up like you could in Sublime 2.
-
Eliza Weisman over 10 years@MattDMo: oh, yeah, I didn't notice he had tagged his post as sublimetext3.
-
Abu Shumon over 6 yearsBut 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.
-
Mark about 5 years
"open_files_in_new_window": false,
didnt work for me. So this answer was golden! -
Dee about 5 yearstks, this is what i want, hell yeah
-
Argyll almost 5 yearsDoesn't work for folders for me. (Using Windows 7.)
-
Qwerty over 3 years@Argyll This setting only works for macOS
-
Joel Mellon over 3 yearsUgggh, this only works when opening files from Finder or other system stuff, not the built-in
subl
console command. 🤦🏻♂️ -
ymoreau about 2 yearsI don't see that parameter with Monterey version.
-
panjeh about 2 years@ymoreau I updated my article here: panjeh.medium.com/… and also edited my post in stackoverflow