简体   繁体   中英

vscode interesting undocumented feature

I got an interesting feature from vscode, but did not retrieved how I had it:

from the windows explorer, while trying an opening of vs code for a file with a right click, I put inadvertendly my hand on the keyboard and obtained an opening of the folder of the file.

This is something I like: when I want to open a file in a folder, it is rarely the only one I want to open. Today I have to go back to the folder, right click th folder then be able to open the folder.

does one of us get the same thing? do you remember how you get that?

You are describing Windows Context Menu. There is an option to add Open with Code action to the Windows Explorer directory context menu when you install VSCode.

在此处输入图像描述

If you selected it, you should have a point saying something like on the image below when you right-click on a folder or empty space within the folder in Windows Explorer:

在此处输入图像描述

If it's not there, you can still open entire folders from within VSCode:

在此处输入图像描述

Alternatively, you can add Open with Code to the Windows Context Menu yourself. To do it, create a new file with .reg extension (eg vsCodeOpenFolder.reg) and paste the following code into it, save, and execute it by double-clicking the new file. Note, C:\\Program Files\\Microsoft VS Code\\Code.exe in the code below is the default location of your VSCode executable. In order for the code below to work, ensure you actually have Code.exe there or change the script to match your setup.

Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

Note: The code above adds new entries to your Windows Registry. Before executing it, read through and make sure you understand what it does.

I have found how to obtain vs code opening the current folder from windows explorer: right click OUT of a file name (in a white area). The context menu displays 'open with code'. this one open the current folder of the windows explorer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM