146

I've got a component-based folder structure in my project. It is a bunch of component-folders with one index.js file each.

Is it possible to make Visual Studio Code display the parent folder name in the file tabs? Or am I limited to seeing a bunch of tabs that all display index.js and nothing else?

Enter image description here

3
  • There is a thread about it here https://github.com/Microsoft/vscode/issues/8499
    – Anish
    Commented Oct 31, 2016 at 13:52
  • 6
    This setting will show the full path in the title bar (though not the tab): “window.title”: “${activeEditorLong}${separator}${rootName}”
    – edan
    Commented Mar 30, 2018 at 16:34
  • ${activeEditorMedium}${separator}${rootName} works even better imo, I don't see a reason to see the entire path of the file as opposed to path from src root
    – Siddhartha
    Commented Nov 30, 2021 at 2:14

9 Answers 9

292

You can configure Visual Studio Code to always show parent folder names in the tabs! In your User Settings, just add this line: "workbench.editor.labelFormat": "short" (other values are "long", "medium" or "default")

Result: the files init/views.js, init/routes.js and plugins/modal.js will be presented as such:

Screenshot of Visual Studio Code file tabs


Another option is the User Setting "breadcrumbs.enabled": true which for shows a row of breadcrumbs with the complete file path - in the Code view below the Active tab.

Screenshot of breadcrumbs


PS: To open User Settings use the File-menu → PreferencesSettingsUser Settings. To view the settings in a JSON format just click the {} icon in the top right corner.

0
32

Go to the main menu FilePreferencesSettings. And search for (Cmd + F on Mac; Ctrl + F on Windows and Linux) workbench label format.

Choose the short option.

7
  • There are two "Label Format" in the search result: "Workbench ► Editor: Label Format" and "Workbench ► Editor ► Untitled: Label Format" Commented May 12, 2020 at 22:27
  • For version 1.45 (2020-04). Commented May 12, 2020 at 22:51
  • The second has different options, "Content" and "Name" Commented May 12, 2020 at 23:23
  • 1
    Enclosing in quotes cuts the number of hits down from 34 to 7 (version 1.45.1, 2020-05-14): "workbench label format" Commented Jun 9, 2020 at 12:18
  • 1
    The search can be made unique (only one search hit) by typing out (or pasting) the setting ID: workbench.editor.labelFormat Commented Jun 9, 2020 at 12:55
9

I know this is too late to answer, but in case someone is looking for the file path to show on the title bar, you can follow this:

  1. Open settings (command + ,)
  2. Search for title
  3. You'll see something like activeEditorShort, replace it with activeEditorLong
  4. Save

Source: https://medium.com/riow/vscode-show-full-path-in-title-bar-b0cb731b330

0
7

Visual Studio Code has now improved their tab-UI to resolve this issue.

When you've opened multiple tabs with the same filename, Visual Studio Code will automatically display the parent foldername in each of those tabs.

Here's an example: I've opened two index.js files and one event.js file. VsCode decides it's a good idea to display the foldername for the index.js files but not for the event.js file since that filename is unique

This is enough for me in some situations (when I've got lots of files with the same name)

1
  • 9
    There is also a setting to control the behavior and format of the label: "workbench.editor.labelFormat"
    – Ej.
    Commented Oct 23, 2017 at 18:54
5

Step 1: Go to File > Preferences > Settings

Step 2: search for "workbench.editor.labelFormat"

Step 3: select medium from a drop-down

4

In vscode v1.88 ( Release Notes: custom editor names):

Custom labels for open editors

We now offer the ability to customize editor labels for the tab bar and the open editors view. You can tailor these labels to your preference by adding entries under the workbench.editor.customLabels.patterns setting. Each entry should include a glob pattern that matches file paths and a template that defines the new name for the editor tab. This customization only applies when a file's path matches the specified pattern. Whether a pattern matches depends on if it's defined as a relative or absolute file path pattern.

Templates can incorporate variables such as ${filename}, ${extname}, ${dirname}, and ${dirname(N)}, which are dynamically replaced with values from the file's path.

To enable or disable the application of these custom labels, use the workbench.editor.customLabels.enabledsetting. This allows you to view the original editor names at any time without needing to remove your custom patterns.


You will be able to change your tab names to something like /parentFolder index using this value:

\${dirname} {filename}

in the setting:

Workbench > Editor > CustomLabels : Patterns

(setting ID workbench.editor.customLabels.patterns)

See more at Provide api to access and change editor tab labels

1
3

Video reference codeGrepper

Go to vs code setting and search "Label format" you will see

Workbench › Editor: Label Format Controls the format of the label for an editor.

change from default to short.

0

You can install the nice-index extension for a better experience dealing with index files.

However, as of now, it only works when you have more than one index file open. This can be resolved by changing labelFormat to "short", as other answers suggest.

2
  • 1
    The link leads to a 404 error page.
    – Hassan
    Commented Dec 5, 2022 at 10:40
  • Seems like the plugin was discontinued. I stopped using it months ago and rather stopped using index files at all, it was a nightmare to keep an overview of which tab is which file.
    – Vitexikora
    Commented Dec 6, 2022 at 14:11
-1

In VSCode 1.53 you can use thees settings:

Controls the window title based on the active editor. Variables are substituted based on the context:

${activeEditorShort}: the file name (e.g. myFile.txt).
${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).
${activeEditorLong}: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).
${activeFolderShort}: the name of the folder the file is contained in (e.g. myFileFolder).
${activeFolderMedium}: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).
${activeFolderLong}: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).
${folderName}: name of the workspace folder the file is contained in (e.g. myFolder).
${folderPath}: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).
${rootName}: name of the opened workspace or folder (e.g. myFolder or myWorkspace).
${rootPath}: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).
${appName}: e.g. VS Code.
${remoteName}: e.g. SSH
${dirty}: a dirty indicator if the active editor is dirty.
${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.
1
  • 2
    While this is useful, it's unrelated to the question, which is about setting the titles of the editor tabs.
    – Théophile
    Commented Sep 22, 2021 at 16:40

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