美文网首页
修改VSCode的插件安装目录

修改VSCode的插件安装目录

作者: rosy_dawn | 来源:发表于2021-10-11 17:44 被阅读0次

    VSCode 的插件目录在各平台下的默认位置如下:

    Windows %USERPROFILE%\.vscode\extensions
    macOS ~/.vscode/extensions
    Linux ~/.vscode/extensions
    

    Windows 系统中 VSCode 编辑器的插件目录默认在 C 盘,extensions 目录会很大,我们可以通过自定义 VSCode 插件安装位置来解决:

    方法一(推荐,不用每次重启电脑):

    前提是已安装 VSCode,并且已将其添加到了环境变量 path 中。打开 VSCode,然后在打开的 VSCode 中点击 Terminal 菜单栏的 New Terminal 菜单,输入命令code --help 命令可以查看帮助,输入 code --extensions-dir "your extensions dir" 命令来指定插件目录。如下所示:

    PS C:\Users\Vincent Huang> code --help
    Visual Studio Code 1.44.2
    
    Usage: code.exe [options][paths...]
    
    To read output from another program, append '-' (e.g. 'echo Hello World | code.exe -')
    
    Options
      -d --diff <file> <file>           Compare two files with each other.
      -a --add <folder>                 Add folder(s) to the last active window.
      -g --goto <file:line[:character]> Open a file at the path on the specified
                                        line and character position.
      -n --new-window                   Force to open a new window.
      -r --reuse-window                 Force to open a file or folder in an
                                        already opened window.
      --folder-uri <uri>                Opens a window with given folder uri(s)
      --file-uri <uri>                  Opens a window with given file uri(s)
      -w --wait                         Wait for the files to be closed before
                                        returning.
      --locale <locale>                 The locale to use (e.g. en-US or zh-TW).
      --user-data-dir <dir>             Specifies the directory that user data is
                                        kept in. Can be used to open multiple
                                        distinct instances of Code.
      -h --help                         Print usage.
    
    Extensions Management
      --extensions-dir <dir>                            Set the root path for
                                                        extensions.
      --list-extensions                                 List the installed
                                                        extensions.
      --show-versions                                   Show versions of installed
                                                        extensions, when using
                                                        --list-extension.
      --category                                        Filters installed
                                                        extensions by provided
                                                        category, when using
                                                        --list-extension.
      --install-extension <extension-id | path-to-vsix> Installs or updates the
                                                        extension. Use `--force`
                                                        argument to avoid
                                                        prompts.
      --uninstall-extension <extension-id>              Uninstalls an extension.
      --enable-proposed-api <extension-id>              Enables proposed API
                                                        features for extensions.
                                                        Can receive one or more
                                                        extension IDs to enable
                                                        individually.
    
    Troubleshooting
      -v --version                       Print version.
      --verbose                          Print verbose output (implies --wait).
      --log <level>                      Log level to use. Default is 'info'.
                                         Allowed values are 'critical', 'error',
                                         'warn', 'info', 'debug', 'trace', 'off'.
      -s --status                        Print process usage and diagnostics
      --prof-startup                     Run CPU profiler during startup
      --disable-extensions               Disable all installed extensions.
      --disable-extension <extension-id> Disable an extension.
      --sync <on> <off>                  Turn sync on or off
      --inspect-extensions <port>        Allow debugging and profiling of
                                         extensions. Check the developer tools for
                                         the connection URI.
      --inspect-brk-extensions <port>    Allow debugging and profiling of
                                         extensions with the extension host being
                                         paused after start. Check the developer
                                         tools for the connection URI.
      --disable-gpu                      Disable GPU hardware acceleration.
      --max-memory                       Max memory size for a window (in Mbytes).
      --telemetry                        Shows all telemetry events which VS code
                                         collects.
    
    PS C:\Users\Vincent Huang> code --extensions-dir "D:\development\tools\VSCode-win32-x64-1.46.1\resources\app\extensions"
    PS C:\Users\Vincent Huang> 
    

    方法二

    右键桌面的 VSCode 快捷方式,点击属性,将目标

    D:\development\tools\VSCode-win32-x64-1.46.1\Code.exe
    

    修改为:

    D:\development\tools\VSCode-win32-x64-1.46.1\Code.exe --extensions-dir "D:\development\tools\VSCode-win32-x64-1.46.1\resources\app\extensions"
    

    添加了code --extensions-dir "your extensions dir" 命令之后就会使用新的插件目录。

    相关文章

      网友评论

          本文标题:修改VSCode的插件安装目录

          本文链接:https://www.haomeiwen.com/subject/cytroltx.html