Open current editing file in explorer tree

Visual Studio-Code

Visual Studio-Code Problem Overview


I'm wondering if there is a shortcut for VS Code that highlights in solution explorer tree current opened file. Like we have in Visual Studio:

Alt + Shift + L

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

Couldn't live with no complete answer, so figured out the following:

Without a direct keyboard shortcut:

  1. Open the command palette via Cmd-Shift-P (or Cmd+P then >) and type Files: Reveal Active File in Side Bar.
  2. This reveals the active file in the side bar similar to Visual Studio's Alt+Shift+L

Then, take the above and map a keyboard shortcut to it:

  1. Open keyboard shortcut preferences file via Cmd-Shift-P followed by Preferences: Open Keyboard Preferences File.
  2. Add in the following (taking Visual Studio's lead, I've personally mapped it to Alt+Shift+L, but map to what you want).

// Place your key bindings in this file to overwrite the defaults      
[  {    "key": "shift+alt+l",    "command": "workbench.files.action.showActiveFileInExplorer",  },]

Note that it's not as good as Visual Studio, Atom, etc. in that you can't then navigate with arrow keys in the tree (arrow keys navigate the active file contents), but I guess I'll eventually figure out how to do that.

@Tomoyuki Aota points out that you can do the following to navigate with arrow keys:

> After Files: Reveal Active File in Side Bar, press Ctrl+Shift+E (Show > Explorer). After that, I can navigate the files in the explorer by the > arrow keys.

Solution 2 - Visual Studio-Code

I don't think there's a command for that, but there is a shortcut to enable/disable revealing the current file as you open it:

"explorer.autoReveal": true

Solution 3 - Visual Studio-Code

Try this:

Together with @Rob's correct answer:

"explorer.autoReveal": true

then Ctrl-Shift-E (Show explorer) focuses that file in the explorer and the arrow keys will navigate up/down/left/right like any list. This works even if the explorer is closed prior to the Ctrl-Shift-E.

Ctrl-Shift-E has the added bonus in that it will toggle focus between the highlighted file and its editor as well.

For mac, use Cmd-Shift-E

Solution 4 - Visual Studio-Code

Right-click the file tab (not necessarily current one) and click "Reveal in Side Bar".

enter image description here

Solution 5 - Visual Studio-Code

I was able to achieve this by customizing the workbench.files.action.focusFilesExplorer command with keybinding Alt + shift + L

  1. Open the Keyboard Shortcuts ctrl + K + shift + S
  2. search for focusFilesExplorer command & customize
  3. Provide your keybindings that you are used to - I set mine to Alt + Shift + L

Solution 6 - Visual Studio-Code

F1 then type "reveal" also works from in VS Code, at least for me.

Solution 7 - Visual Studio-Code

It looks like the actual version of VS Code offers a command for this feature now. In the settings, type revealInExplorer in the search bar to find the command. There is no default keybinding, so just put your own. Works like a charm!

Solution 8 - Visual Studio-Code

Download the open in browser extension, that's it.
Right click > Open in primary/secondary browser function appears, and the ALT+B / ALT+SHIFT+B shortcuts become available.

Solution 9 - Visual Studio-Code

Had a similar case and ended up here looking for help.

I opened a file in "preview" mode after clicking a link in a .md file and wanted to know where this opened file was located in the project.

I found this button in the upper right corner of VS Code which was exactly what I wanted:

show source

It's called "show source"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVnuukView Question on Stackoverflow
Solution 1 - Visual Studio-CodeTedView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeRob LourensView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeMarkView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeDen KasyanovView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeNarenView Answer on Stackoverflow
Solution 6 - Visual Studio-CodeRollingInTheDeepView Answer on Stackoverflow
Solution 7 - Visual Studio-CodeCarrmView Answer on Stackoverflow
Solution 8 - Visual Studio-CodeAttila MarossyView Answer on Stackoverflow
Solution 9 - Visual Studio-CodeAlvaro Rodriguez ScelzaView Answer on Stackoverflow