Open files and folders in same window in Sublime Text

☆樱花仙子☆ 提交于 2019-12-31 08:42:42

问题


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?


回答1:


In Sublime Text Menu:

Preferences ->  Settings - User

Look for 'open_files_in_new_window'

And change 'true' with 'false'




回答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.




回答3:


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




回答4:


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.




回答5:


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



回答6:


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




回答7:


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!!



来源:https://stackoverflow.com/questions/21023529/open-files-and-folders-in-same-window-in-sublime-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!