I am wondering if there is a way I could bind a keyboard shortcut to open the OS File Explorer at the root workspace directory.
Furthermore, I would also like to be able to open a specific folder, relative to my workspace path, with the press of a keyboard shortcut.
I have search through the settings file, and for extensions, but I didn't come up with anything yet.
Hit Cmd + O on macOS or Ctrl + O on Windows/Linux to activate the open dialog, select a folder, and click "Open." Note: This answer was written before multiple folder workspaces were implemented in VS Code. If you open folders this way, it will replace your entire workspace with the folder you selected to open.
You can define a keyboard shortcut for any task. From the Command Palette (Ctrl+Shift+P), select Preferences: Open Keyboard Shortcuts File, bind the desired shortcut to the workbench.action.tasks.runTask command, and define the Task as args .
You can look at it by opening it with a text editor. Close the folder you created and close Visual Studio Code. Now find your workspace "file" and double click on it. This will open Visual Studio Code with the folder you created in your workspace.
One way to accomplish this would be by using a task and a keybinding.
Workspace Folder
To open the workspace using shiftctrlalt + t, create a task:
tasks.json
{
"label": "explore workspace",
"type": "shell",
"windows": {
"command": "explorer ${workspaceFolder}"
},
"osx": {
"command": "open ${workspaceFolder}"
}
}
Note the task label. Ad a corresponding keybinding:
keybindings.json
{
"key": "ctrl+shift+alt+t",
"command": "workbench.action.tasks.runTask",
"args": "explore workspace"
}
Note the args
value matches the task's label
value.
Folder relative to workspace
Assume you want to open ${workspaceFolder}/node_modules/.bin
. Add the task:
{
"label": "explore bin",
"type": "shell",
"windows": {
"command": "explorer ${workspaceFolder}\\node_modules\\.bin"
},
"osx": {
"command": "open ${workspaceFolder}/node_modules/.bin"
}
}
and a corresponding keybinding:
{
"key": "ctrl+shift+alt+r",
"command": "workbench.action.tasks.runTask",
"args": "explore bin"
}
Disclaimer: Only tested on Windows
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With