Open current editing file in explorer tree
Visual Studio-CodeVisual 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:
- Open the command palette via Cmd-Shift-P (or Cmd+P then >) and type
Files: Reveal Active File in Side Bar
. - 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:
- Open keyboard shortcut preferences file via Cmd-Shift-P followed by
Preferences: Open Keyboard Preferences File
. - 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
Solution 5 - Visual Studio-Code
I was able to achieve this by customizing the workbench.files.action.focusFilesExplorer
command with keybinding Alt + shift + L
- Open the Keyboard Shortcuts ctrl + K + shift + S
- search for focusFilesExplorer command & customize
- 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:
It's called "show source"