Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open files in new tabs in Visual Studio Code

I recently started using Visual Studio Code and I would like to know, is a way to open files in a new tab? Currently whenever I open a new file the files I currently have open disappear. I say new tab, but any option that will let me open a new file in the same window as the old one works.

I have tried disabling Preview Mode through the workbench settings as shown in this answer: How to config vscode to open files always in a new tab?. However, when I choose Open or Open Recent the new file still replaces my old file.

Thanks.

like image 365
CharType Avatar asked Aug 25 '18 03:08

CharType


People also ask

How do I open files in a different tab in VS Code?

Hold Ctrl and press Tab to view a list of all files open in an editor group. To open one of these files, use Tab again to pick the file you want to navigate to, then release Ctrl to open it. Alternatively, you can use Ctrl+Alt+- and Ctrl+Shift+- to navigate between files and edit locations.

How do I open a new tab in Visual Studio?

To open a new tab in VS Code, all you need to do is double-click it instead of single-clicking it.


3 Answers

Once you have to open your settings file, add the "workbench.editor.enablePreview" property and set value to false.

like image 162
Akil Makda Avatar answered Oct 19 '22 05:10

Akil Makda


For 1.21.1 version.

In user settings =>

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

the best way i found.

like image 36
Jean-Noël Devisme Avatar answered Oct 19 '22 05:10

Jean-Noël Devisme


Starting with VSCode 1.52 (Nov. 2020), you should not have any more issue: all files will open in new tabs, even in preview mode.

Better handling of preview editors:

Preview editors are now better handled with numerous improvements based on feedback and making this feature work more consistent.

The setting workbench.editor.enablePreviewFromQuickOpen is now disabled by default so that editors opening from quick open will not appear in preview mode anymore.

When you start a navigation (e.g. go to definition), the editor you start from will move out of preview mode to keep it open while the new editor will be in preview mode until you navigate further.

Go to definition -- https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_52/goto-definition.gif

We changed all of our custom trees (the ones used from extensions or Git changes view for example) to work more consistently like our built-in trees (like the explorer).
This means, the following interactions now apply to all of them:

  • double-click or mouse-middle-click to open non-preview
  • Enter to open non-preview (Space to open in preview-mode)

Note: if you are the author of an extension that is leveraging our custom tree API, you can benefit from this change as well.
Make sure to use vscode.open or vscode.diff commands for the TreeItem.command and you are in!

A new menu item in the editor overflow menu allows to quickly turn off preview editors altogether:

Keep Open -- https://media.githubusercontent.com/media/microsoft/vscode-docs/vnext/release-notes/images/1_52/keep-open.png

like image 35
VonC Avatar answered Oct 19 '22 03:10

VonC