VS Code – How to Open File in New Tab

VS Code is a coding tool that’s renowned for its popular design, user-friendliness, and innovative features. The VS Code tabs make this program incredibly functional and well-organized. But knowing how to handle them is absolutely essential.

If you are new to coding, you’re likely to get confused by the way tabs work here. It’s not like your regular browser tabs.

In this guide, we’re going to teach you how to navigate VS Code and make it work to your benefit.

How to Open a File in a New Tab in VS Code

Okay, so you’ve started VS Code for the first time, and you’re navigating the Explorer root menu to the left. Each entry you click, however, changes the tab. Well, what’s the point of tabs, if they keep changing each time you open them, you may wonder. Hold on; there’s a simple way to change this.

To open a new tab in VS Code, all you need to do is double-click it instead of single-clicking it. This may seem a bit weird and confusing, but once you’ve gotten used to this function, you’ll realize that it actually makes your job much easier.

When you think about it, if a new tab opened each time you single-clicked an entry in the Explorer menu, this would create a lot of confusion, especially if you are working with multiple tabs simultaneously (which you often will be).

How to Lock a Tab in VS Code

The double-click tab opening function in VS Code might be different from that of other code editors, but it’s actually a great option in practice. Once you’ve got the hang of it, you’ll be able to effortlessly shuffle between tabs, opening new ones, and locking the important ones.

If you are working on something important, you’re not going to like it when you accidentally single-click an entry in the Explorer list. This will throw you off and result in a loss of focus.

Thankfully, VS Code offers an option that allows you to make a tab “sticky.” In other words, you can lock it, which means that once you single-click an entry from the Explorer list, it will open a new one and keep the locked tab open. There are a few ways to do this.

The most straightforward method is to double-click the tab involved. You’ll note that its name is going to turn from italicized (Preview Mode) to normal. Another way to do this is to use the Ctrl+K+Enter command while the tab in question is opened and in focus. Finally, right-click the tab and select Keep Open from the dropdown menu.

How to Open a File in a New Tab by Default in VS Code

If you’re working in multiple code editors and the weird tab opening method is frustrating you, you might want to use VS Code to automatically open files in new tabs. Alternatively, maybe you prefer it that way – who are we to judge?

Here’s how to override this and change the typical VS Code tab-opening behavior.

Use the “workbench.editor.enablePreview” setting to disable or enable the Preview Mode for new tabs completely. This means that each new tab will open in “sticky” mode, thereby diminishing the need for using the double-click function. This method, however, will also completely abolish the Preview Mode, which can sometimes be useful.

There’s also the “workbench.editor.enablePreviewFromQuickOpen” command, which adds a Preview Mode option to VS Code’s Quick Open menu.

To use either of these two commands, you’re going to have to tweak the Settings file. Here’s how to do this:

  1. Open the Command Palette using the Ctrl+Shift+P shortcut.
  2. Type in “Preferences: Open User Settings”.
  3. Go to “workbench.editor.enablePreview” using the search bar.
  4. Turn it off.

Do the same for the “workbench.editor.enablePreviewFromQuickOpen” command to enable access to it from the Quick Open menu.

How to Open Multiple Tabs in VS Code

Opening multiple tabs in VS Code is very straightforward. Double-click each entry from the Explorer list. However, to lock the tabs in place and prevent the single-click function from closing them, make sure that you double-click each one. Either that or use the “workbench.editor.enablePreview” command to open each new tab using one click.

Why Has VS Code Made Tabs Different Than Other Code Editors

As a new VS Code user, you might be wondering why they’ve made tabs function the way they have. After all, in other code editors, things are much more straightforward, right?

The VS Code’s method of opening, swapping, and locking tabs wasn’t implemented by accident. You can rest assured that there’s an entire team of UX (user experience) professionals who determined that this was the right way to go. After a while, you’ll get used to these commands, and we are certain that you’re going to appreciate them better than those in other code editors.

The thing is, when you’re programming, you often need to refer to a file for a second. Maybe copy a line, maybe as a quick reminder. For instance, let’s say that a project keeps returning with a strange error. You’ve pinpointed where the error probably lies – in one of the config files. VS Code allows you to open these files within a single tab.

Instead of double-clicking each one and going back and forth between the two tabs, you can single-click their entries in the Explorer list to the left. In addition to being less confusing, being able to navigate through these tabs in Preview Mode will help you form a clearer picture of where they’re located.

This doesn’t mean much when you’re working on a few lines. However, if you’re editing code within multiple files, you don’t need any extra tabs adding to the clutter and wasting your focus, time, and energy.

Another benefit of the Preview Mode is seen in debugging. Instead of having to open a bunch of tabs and close them to avoid the clutter, quickly shuffle through the files from the Explorer list.

The VS Code Tab Downside

Being used to other code editors isn’t a real downside – some people are used to VS Code, like you may be used to Notepad++. However, there is a scenario where the way the VS Code tabs function can be seen as a downside. If you’re working with a large number of files, you may happen to forget to make a tab sticky (double-click). With a huge Explorer list to the left, you’ll be left losing focus, trying to find the file in question again.

However, there’s a silver lining here – the way VS Code tabs work makes you more alert and careful when coding. Plus, in reality, you’ll eventually get used to VS Code, and you won’t make mistakes like these.

Additional FAQ

How do you open a new file in VS Code?

Start by opening the VS Code project in question. Then press Ctrl+Shift+P to open the Command Palette. Alternatively, go to View, and select the Command Palette. From the list, select Create New File. You’ll be prompted to select which file type you want to create. Find the file type on the list or type it in. Now, confirm, and you’ve successfully created a new VS Code file.

How do I open a new terminal tab in VS Code?

In VS Code, there’s a feature called the Integrated Terminal, which makes organizing things much easier. To open this terminal, press Ctrl+`. Alternatively, navigate to the View tab, followed by the Terminal command. Now, navigate to the Command Palette, and go to View. Then, use the Toggle Integrated Terminal function to turn the Integrated Terminal on or off.

How do I open files side-by-side in VS Code?

Navigate to the Explorer list to the left. Press Alt and click on a file. Press Ctrl+\ – this will split the editor into two parts. Press Ctrl+Enter to open the Explorer context menu. Select Split Editor (upper right part of the editor). Now, drag & drop the file in question to either of the editor sides.

How do you edit multiple lines in VS Code?

If you’re a Notepad++ user, you will probably be familiar with the multi-line editing feature. In Notepad++, it’s called “column mode editing.” If you don’t know what multi-line editing entails, it’s a function that allows you to make changes on more than one text instances over contiguous lines. You can replace these lines with information that is identical or similar. This is particularly useful for HTML. To use multi-line editing, use the Ctrl+Alt+Arrow Keys command.

How do I make multiple cursors in VS Code?

For quick, simultaneous edits, VS Code employs the multi-cursor feature. To add a secondary cursor, press Alt+Left-Click. To insert more cursors above or below, use the Ctrl+Alt+Down and Ctrl+Alt+Up functions, respectively. Keep in mind, though, that your GPU (NVIDIA, in particular) may overwrite the shortcuts. To select a word as a cursor, use Ctrl+D.

VS Code Tabs

VS Code is definitely unique when it comes to how its tabs work. However, many professionals find this way superior to that of other code editors. In any case, if you don’t like the Preview Mode tab function, you can follow one of the mentioned methods to make VS Code work like any other code editor.

Have you figured out how to deal with VS Code tabs? Do you now prefer it to other editors? You can hit the comments section below this entry if you have anything to add or ask regarding the subject of VS Code tabs. Don’t be a stranger! Our community is always more than happy to help.

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.