52

How can multiple files be opened in Visual Studio Code (VSC)?

For some reason, my copy of Visual Studio Code can only open one file at a time. For example, if there are two files in the workspace folder, let’s say an HTML and CSS file, both cannot be opened simultaneously. If one file is open, clicking any other item in VSC's file explorer will replace the current file. VSC will not open the other file in a new editing tab.

I am not concerned with running multiple instances, Workspaces or folders of VSC. I just want to open two files in the same folder. Is there a configuration setting controlling this? Or is this the result of upgrading to the latest version of VSC? Is just a "new feature" of VSC?

It's seems ridiculously simple, but I need help. I am running Visual Studio Code v. 1.24.0 for Windows 10 64 bit.

Visual Studio Code screenshot:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Native New Yorker
  • 521
  • 1
  • 4
  • 7
  • 2
    Possible duplicate of [VSCode showing only one file in the tab bar (can't open multiple files)](https://stackoverflow.com/questions/48589785/vscode-showing-only-one-file-in-the-tab-bar-cant-open-multiple-files) – Ken Y-N Jun 13 '18 at 01:18
  • 1
    Its not a duplicate, in the linked issue tabs were entirely disabled. The described problem explains only the fact that single-clicking VSCode files does not open a new tab. – Lukas Bach Jun 13 '18 at 01:20
  • 1
    I never though they will make me to search for solution on "How to open files in separate tabs in editor", in 2022. But here we are. Welcome to VS Code. – Atul Jan 25 '22 at 05:22

12 Answers12

73

In Visual Studio Code, if you click once on a file, it opens it in a temporary tab. This is helpful if you are looking into a bunch of files searching for something, without opening every single one of them.

If you want to open a file in a new tab that persists until closed manually, double-click on the file.

You can also persist a tab that was previously created as a temporary tab by double-clicking on the tab. Note that temporary tabs have an italicized title, while normal tabs do not.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lukas Bach
  • 3,559
  • 2
  • 27
  • 31
  • 1
    The file will also remain open if you make edits of any kind to it. But if you're looking to open several from the get-go, double clicking is the way to go. – jmcgriz Jun 13 '18 at 14:24
  • 5
    If you're a keyboard user (I open files using ctrl+P), go to the "possible duplicate" question referenced above and see the answer with `"workbench.editor.enablePreview": false` – dudeNumber4 Sep 19 '18 at 19:50
  • 3
    Seriously, who are guys behind these decisions? It's really painful to search for all the forums on the Internet for plain simple intuitive thing which works in thousands of other similar applications. Many thanks for your answer. It's "double click". – Atul Jan 25 '22 at 05:23
  • @Atul, the same hermits who came up with the Git UI, with the secret agenda of turning StackOverflow into a [crooked temple dedicated to it](https://stackoverflow.com/questions?tab=Votes). – Sz. Mar 18 '22 at 09:34
  • Thanks a lot for the solution. Shame on whoever decided this was a sane default. – eang Aug 22 '22 at 09:43
31

Others have mentioned double-clicking the file in order to open it, however, I will suggest an alternative approach:

Within your settings, under workbench, set:

"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false

This will allow you to open the files with a single click, as opposed to double-clicking. It may seem minute, but it was incredibly annoying to have to double-click every single file.

artemnih
  • 4,136
  • 2
  • 18
  • 28
foxsimile
  • 311
  • 3
  • 2
9

Visual Studio Code, by default, keeps this option enabled to open a file in a temporary file. This feature comes in handy when you want to just take a look at some code.

If you want to open a file in a new tab, just double click on the tab or double click on the folder you want to open from explorer or once the file is opened press the shortcut key Ctrl + K + Enter.


You can even disable this option in menu FilePreferencesSettings, under the user settings.

Paste this code in your user's setting.

"workbench.editor.showTabs": false
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yashu Mittal
  • 1,478
  • 3
  • 14
  • 32
8

Please follow below steps:

Menu FilePreferencesSettings. Now you will see USER SETTINGS and WORKSPACE SETTINGS.

Click on WORKSPACE SETTINGS. Now search for workbench.editor.showTabs and change its value to true.

I tested this by turning it false and it restricts from opening multiple files in tabs. When it's false, whenever you open one file, only that file will be opened and the earlier file gets closed.

When set to true, you can open as many files you want and all files will be a new tab.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dkm007
  • 145
  • 2
  • 6
5

Go to 'settings' in Visual Studio Code and search for 'preview'. Then on the second position from the top you will find "Workbench › Editor: Enable Preview". Simply untick it and your problem will be solved.

In this GIF you can see it's working properly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Anuj Singh
  • 96
  • 1
  • 4
3

If you Ctrl + click or Shift + click and highlight all the files in the sidebar, then you can click and drag them all to whatever area of the editor you want.

Visual Studio Code open multiple files

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
origamifreak2
  • 193
  • 1
  • 1
  • 10
  • Thanks. With those selected files, I tried Right click or Ctrl-Shift-P, but unable to open them all in the first editor group. I didn't know I can drag! – Johnny Wong Mar 22 '23 at 06:56
3

Try the three dots on the upper right hand side corner, right beside the icon for splitting the editor.

From the drop down, check if the option keep editors open is enabled. If not, enable it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2
  • Go to Setting

  • type 'json' in the search box

  • under 'Launch', click on "edit in setting json"

  • then change the workbench.editor from false to true shown below.

    "workbench.editor.showTabs": true,
    "workbench.editor.enablePreview": true
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
codegal
  • 21
  • 1
1

Visual Studio Code, open settings, search for "showTabs" and check or enable checkbox.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jason Spence
  • 472
  • 5
  • 16
  • Re *"open settings"*: *How* exactly? Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/57858856/edit), not here in comments (******* ***without*** ******* "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Jan 23 '23 at 22:10
  • `Ctrl` + `,` (comma)? Or something else? – Peter Mortensen Jan 23 '23 at 23:24
1

Double-click on the file and it will be opened permanently in the Visual Studio window until closed manually.

If you single click on the file, then the file can be replaceable if some other file is opened.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhilash Ramteke
  • 367
  • 1
  • 4
  • 11
1

Just double-click on files to open in new tab.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Short answer:

  1. Double-click on the file. (or)
  2. Ctrl + K + Enter and single-click on the file.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131