Sublime Forum

Opening files in new tab (instead of new window)

#1

Is it possible to set SublimeText 2 on Mac to never open a new window and to always open files in new tabs when I double-click on them in Finder. I know I can drag-drop files into SublimeText but it’s kinda slow…

Thanks
Milos

1 Like

#2

The open_files_in_new_window setting controls this

0 Likes

How to open files in finder in sublime text in a new tab instead of new window by default
#3

Open settings (Cmnd+,), then add the following line between { }:
"open_files_in_new_window": false

2 Likes

#4

Perfect! Thanks a lot!

0 Likes

#5

This really should be the default behavior. However, I probably wouldn’t have learned about this preference file if I didn’t find this in the forum. :stuck_out_tongue:

0 Likes

#6

perfect that worked well. It was listed in the Preferences Settings within Sublime.

0 Likes

#7

Thanks for this @almone!

Worked like a charm. For anyone else just make sure to end “open_files_in_new_window”: false with a comma

“open_files_in_new_window”: false,

0 Likes

#8

Doesn’t work for me. When I set up a Project, then click on the files listed under FOLDERS to open them, the contents of each file replaces the previous, so I am left with only one tab containing the last file clicked, instead of many tabs, each containing one file of the project. (This is under Windows.)

0 Likes

#9

Answering my own question: apparently, Sublime has a “preview mode” that happens when you click a file link. Although previewed files can be edited, they share the same tab. The only solution seems to be to add another setting (in Menu > Preferences > Settings) as follows:

“preview_on_click”: false,

However, you now have to click a file in the left pane twice, not once. There seems to be no other solution to this weirdness in Sublime. Is there any way to open all the files in tabs when one switches to a project?

0 Likes

#10

Can you elaborate what you mean with this?

0 Likes

#11

Okay, I’m new to Sublime. I was worried that there was no “open all project files” command. But after experimenting some more, I see that when I switch between projects, the tabs also switch to contain the current files for each project. This is what I wanted to happen,.

So the only time an “open all project files” command is needed is if you lose your tabs (close all your files). I guess I can just try to avoid doing this.

Should I delete my question (in bold) and this reply?

0 Likes

#12

No need to delete anything. This is called learning and it was our history for others to learn from us.

You can press Ctrl+Shift+T to reopen closed tabs from a project, but this won’t work on this case:

Other than that, there is no builtin command to open all files from a project. Imagine you have a project with 10.000 files. Running this command would not be nice.

But you can install the package https://packagecontrol.io/packages/SideBarEnhancements

It allows you to select all files on the sidebar and open them at once:
image

Related: Remove Trailing Whitespaces from Project.md

0 Likes

#13

To clarify why I don’t have hundreds of files in my project folders, I use filters to select the files I want:

{
	"folders":
	[
		{
			"path": "C:\\Dropbox\\David\\Data\\Sublime"
		},
		{
			"path": "C:\\Public\\SiteInfo",
			"folder_exclude_patterns":["Old"],
			"file_include_patterns": ["A2Hosting*"],
		},
		{
			"path": "C:\\Dropbox\\David",
			"folder_exclude_patterns":["*"],
			"file_include_patterns": ["Incidents*"],
		}
	]
}
0 Likes

#14

And is the SideBarEnhancements package enough for you?

0 Likes

#15

It is not clear to whom you are replying, me or the original poster. If your comment is to me and aimed at the lack of an “open all project files” command, I don’t see that Side​Bar​Enhancements provides that. It seems mostly to fix a bug (file deletion should move files to recycling/trash) and some directory limitations in Sublime, so it is useful, but does not appear to address the question of how to open all the files in a project. (In my opinion, a project should primarily contain the pathnames of files, not of directories. This opinion conflicts with several text editors, not just Sublime.)

0 Likes

#16

I am talking to you (this post is from 8 years ago, the OP is probably is very far away by now).

As I said before, after installing SideBarEnhancements, you can:

  1. Select all the project files on the sidebar,
  2. Right-click on any of them
  3. And I hit the Edit option.

On this next screenshot, I am selecting like 20 files

  1. And I am Right Clicking in one of them
  2. And I am hitting the Edit option
  3. Doing this, it will open these 20 files at once.
  4. But if I had like 200 files selected, it will open all 200 files at once.
  5. It seems to be very close to the behavior you would like.
  6. Can you select all project files on the sidebar and use this?

This behavior you describe I see mostly on IDE’s. But Sublime Text is a Text Editor. Read this post for more details:

0 Likes

#17

Ah, when I read the description of Side​Bar​Enhancements, I’m afraid I didn’t notice that it makes it easy to open many files at once. I will install it, thanks. Thanks for providing such a great, detailed response.

Visual Studio Code is another editor that is oriented around adding folders (directories) to projects, rather than files. VS Code is not an IDE. I gave VS Code a try before giving up in the face of its incompatibility with what I want in a code editor. I haven’t quite given up on Sublime Text 3 as yet, but it’s been a frustrating evaluation period.

For example, it’s looking like every project I create (I currently have 30 projects defined in my current text editor, NoteTab Pro) will require several lines of JSON to narrow down the files in the folders belonging to the project. That is a LOT of manual effort to define a project.

I’m also considering extending Emacs to maintain projects in just the way I want, but it has been years since I knew how to program Emacs in Emacs-Lisp. I wish I could stay with my ancient editor, which is superior in many ways to the most advanced current editors, but it simply cannot handle Unicode, and some of my projects involve multiple human languages.

1 Like

#18

How I got e.g. ⌘ + , to open in a native tab vs. a window I have:

"native_tabs": "preferred", // Disabled will override the below.
"open_files_in_new_window": "always",

Also works when using subl . in terminal.

Sublime Text v4

0 Likes