93

When I have a file opened, I'd like to have a shortcut to navigate to this file inside the EXPLORER, so that I can see where it is located.

How can I do this?

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Jim Aho
  • 9,932
  • 15
  • 56
  • 87

5 Answers5

162

In the command palette (F1), there is a Files: Reveal Active File in Side Bar command. You can assign a shortcut to it via the keyboard shortcuts editor:

Alternatively, you could try the Reveal extension which adds this button to editors:

It might make sense to disable auto-reveal when using this shortcut as a "manual reveal":

// Set this in your settings.json file
"explorer.autoReveal": false
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
Gama11
  • 31,714
  • 9
  • 78
  • 100
  • 7
    `Shift+Command+P`, enter `Files: Reveal Active File in Side Bar` – likid1412 Feb 14 '20 at 07:45
  • In fresh download of current VSC (version 1.49.3) on Win 10, command palette does not have `Files: Reveal Active File in Side Bar`. Instead, do [rt-click on file tab above source pane / reveal in side bar](https://stackoverflow.com/a/44844331/199364) – ToolmakerSteve Oct 16 '20 at 21:01
  • I bound the command `workbench.files.action.showActiveFileInExplorer` to Ctrl + K B, as R and S were already taken :) – apa64 Nov 03 '20 at 07:17
  • 2
    Is the same thing possible, but with **revealing the file in the *Folders* panel instead**, please? There are several panels in the *Explorer* sidebar (*Open editors*, *Folders*, *Outline*, *Timeline*, *Documentation*, etc.) and the suggested function reveals it in the *Open editors* panel, which has very limited possibilities of what you can do with files there (compare context menus of a file in both panels). In the *Folders* panel, you can rename, delete and copy&paste files, open their timeline, history, etc. – David Ferenczy Rogožan May 25 '21 at 22:35
  • I don't find this functionality very useful. In addition to the points raised by @DavidFerenczyRogožan, files in the same folder typically share a common focus/purpose; for this reason, when I'm viewing/editing a file, I often want to browse through the files near it in the folder tree. A command to reveal the active file in the folder tree would make this easy to do. Sometimes, the "reveal active file in sidebar" cmd does reveal it in the folder tree, though the behavior is inconsistent. – John Colvin Oct 10 '21 at 01:21
31

To show the active file in the Windows-Explorer or sidebar:

  • right-click on the file tab and choose 'reveal in explorer'/'reveal in side bar'

enter image description here

The keyboard shortcut for reveal in windows explorer is is ctrl K R

To show the file in the sidebar you can assign a custom code in the keybindings window:

enter image description here

jps
  • 20,041
  • 15
  • 75
  • 79
  • 5
    Thanks for your tip but i'm looking for a keybinding shortcut. Also, 'reveal in explorer' actually opens it up in the windows explorer. I'm talking about the VS Code explorer here :) – Jim Aho Jun 30 '17 at 10:36
15

Just press Cmd + Shift + E and the explorer will show the file you are viewing.

Khaled Annajar
  • 241
  • 3
  • 5
  • 1
    For me it doesn't work on files the appear in .gitignore since I didn't enable it in the settings under `Features -> Explorer -> Exclude Git Ignore` – MasterPiece May 02 '23 at 14:43
6

Wanted to add that the first answer still works, but that the text was slightly changed to "Reveal in Explorer View" from "Reveal file in sidebar"

enter image description here

and

right clicking on the tab

enter image description here

Gaunt
  • 649
  • 8
  • 20
0

Tested in Visual Studio Code 1.78.0 on Linux Ubuntu 20.04.

No extensions are needed.

Several additional easy ways:

  1. [already mentioned in this answer, where I first learned it]

    Right-click the file tab of interest at the top of the window --> "Reveal in Explorer View", as shown here: enter image description here

  2. The following ways only work if you have either not set a value for "explorer.autoReveal" (since its default value is true), or if you have explicitly set it to true inside your settings.json file, like this:

    // Controls whether the Explorer should automatically reveal and select
    // files when opening them.
    //  - true: Files will be revealed and selected.
    //  - false: Files will not be revealed and selected.
    //  - focusNoScroll: Files will not be scrolled into view, but will still be
    //    focused.
    // GS note: default is `true`
    "explorer.autoReveal": true,
    
    1. [not explained in any other answer yet]

      Click the "Refresh Explorer" button at the top of the File Explorer view:

      enter image description here

    2. [not explained in any other answer yet]

      Click any other file tab at the top of the Window (assuming you have multiple files open), then click back to your file of interest.

    3. [not explained in any other answer yet]

      Press Ctrl + PageDown to navigate one file tab to the right (assuming you have multiple files open), then press Ctrl + PageUp to navigate back to your original file one tab back to the left.

See also the two main answers:

  1. By @Gama11 - where I learned about the reveal command, the Reveal extension, and the "explorer.autoReveal" settings.json setting.
  2. By @jps - where I learned about the Right Click --> "Reveal in Explorer View" menu option.
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265