61

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

3
  • 2
    Possible duplicate of VSCode showing only one file in the tab bar (can't open multiple files)
    – Ken Y-N
    Commented Jun 13, 2018 at 1: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
    Commented Jun 13, 2018 at 1: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
    Commented Jan 25, 2022 at 5:22

12 Answers 12

82

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.

5
  • 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
    Commented Jun 13, 2018 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 Commented Sep 19, 2018 at 19:50
  • 4
    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
    Commented Jan 25, 2022 at 5: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.
    – Sz.
    Commented Mar 18, 2022 at 9:34
  • 2
    Thanks a lot for the solution. Shame on whoever decided this was a sane default.
    – eang
    Commented Aug 22, 2022 at 9:43
33

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.

3
  • this is the right way. Commented Nov 25, 2021 at 4:45
  • What is "your settings"? A JSON file? Something else? Commented Jan 23, 2023 at 23:14
  • Ctrl + , (comma)? Or something else? Commented Jan 23, 2023 at 23:23
10

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

0
6

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.

2
  • Re "Go to 'settings'": How exactly? Commented Jan 23, 2023 at 23:14
  • Ctrl + , (comma)? Or something else? Commented Jan 23, 2023 at 23:24
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

1
  • 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! Commented Mar 22, 2023 at 6: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.

1
  • 2
    This should be a comment
    – kk.
    Commented Apr 9, 2021 at 6:01
2

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

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
    
2
  • This is one of the rare cases where a screenshot would be appropriate (unlike for text/code). Commented Jan 23, 2023 at 23:29
  • Does it actually say "edit in setting json"? Not "Edit in settings.json"? Commented Jan 23, 2023 at 23:29
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.

2
  • Re "Visual Studio": Do you mean "Visual Studio Code"? They are not the same thing (thanks, Microsoft marketing). Commented Jan 23, 2023 at 23:03
  • @PeterMortensen yes I meant Visual Studio Code only :) Commented Jan 25, 2023 at 9:51
1

Visual Studio Code, open settings (command ,) on mac, search for "showTabs" and select "multiple".

2
  • Re "open settings": How exactly? Please respond by editing (changing) your answer, not here in comments (******* without ******* "Edit:", "Update:", or similar - the answer should appear as if it was written today). Commented Jan 23, 2023 at 22:10
  • Ctrl + , (comma)? Or something else? Commented Jan 23, 2023 at 23:24
0

Short answer:

  1. Double-click on the file. (or)
  2. Ctrl + K + Enter and single-click on the file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.