win10 使用 vscode 打开文件(夹)

# win10 使用 vscode 打开文件(夹)

# 一、 通过配置注册表添加鼠标右键命令使用

# 配置注册表文件

  1. 在任意位置新建一个code.txt文件

  2. 复制以下内容到 txt 文件中粘贴

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\shell\VSCode]
    @="Open with Code"
    "Icon"="F:\\Microsoft VS Code\\Code.exe"
    
    [HKEY_CLASSES_ROOT\*\shell\VSCode\command]
    @="\"F:\\Microsoft VS Code\\Code.exe\" \"%1\""
    
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\shell\VSCode]
    @="Open with Code"
    "Icon"="F:\\Microsoft VS Code\\Code.exe"
    
    [HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
    @="\"F:\\Microsoft VS Code\\Code.exe\" \"%V\""
    
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
    @="Open with Code"
    "Icon"="F:\\Microsoft VS Code\\Code.exe"
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode\command]
    @="\"F:\\Microsoft VS Code\\Code.exe\" \"%V\""
    

# 获取 vscode 安装目录

  1. 右键 vscode 桌面图标选择查看文件位置

  2. 获取文件路径 如: F:\xiaoc0727\exebox\Microsoft VS Code

  3. 将以上文件路径修改成 F:\\xiaoc0727\\exebox\\Microsoft VS Code

  4. 复制修改后的路径替换掉 txt 文件中的 F:\\Microsoft VS Code保存

  5. code.txt 文件的后缀 .txt 修改为 .reg

  6. 双击执行code.reg

  7. 执行后会弹出一个提示,点击确定即可,完成后,就可以使用了

  8. 选中文件夹,右键就能看到 Open with Code 这个选项了,点击就能用 vscode 打开文件夹

# 二、 安装 vscode 工具配置命令行 code 命令使用

# 安装 vscode 官方脚手架工具

  1. 使用 yarn 安装

    yarn add global yo generator-code

  2. 使用 npm/cnpm 安装

    npm/cnpm install -g yo generator-code

# 使用

打开命令行,使用 code 文件(夹)路径 即可打开文件(夹)