登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> SoftHub关联区 >> 主题: [vscode]vscode 的命令行参数 -- Visual Studio Code(VS Code)命令行的使用(1)     [回主站]     [分站链接]
[vscode]vscode 的命令行参数 -- Visual Studio Code(VS Code)命令行的使用(1)
clq
浏览(166) - 2023-06-01 19:15:01 发表 编辑

关键字:

[2023-06-01 19:19:19 最后更新]
[vscode]vscode 的命令行参数 -- Visual Studio Code(VS Code)命令行的使用(1)


不过目前 windows 版本的 code --help 是不能直接工作的,原因忘记了。

----------------------------------------------------------------
更新:
是要进入到 bin 目录后再执行以上命令。在 windows 下实际是执行 code.cmd 。 当前我的版本的回应如下

Visual Studio Code 1.78.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.
  -m --merge <path1> <path2> <base> <result> Perform a three-way merge by
                                             providing paths for two modified
                                             versions of a file, the common
                                             origin of both modified versions
                                             and the output file to save merge
                                             results.
  -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.
  -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.
  --profile <profileName>                    Opens the provided folder or
                                             workspace with the given profile
                                             and associates the profile with
                                             the workspace. If the profile
                                             does not exist, a new empty one
                                             is created. A folder or workspace
                                             must be provided for the profile
                                             to take effect.
  -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-extensions.
  --category <category>               Filters installed extensions by provided
                                      category, when using --list-extensions.
  --install-extension <ext-id | path> Installs or updates an extension. The
                                      argument is either an extension id or a
                                      path to a VSIX. The identifier of an
                                      extension is '${publisher}.${name}'. Use
                                      '--force' argument to update to latest
                                      version. To install a specific version
                                      provide '@${version}'. For example:
                                      'vscode.csharp@1.2.3'.
  --pre-release                       Installs the pre-release version of the
                                      extension, when using
                                      --install-extension
  --uninstall-extension <ext-id>      Uninstalls an extension.
  --enable-proposed-api <ext-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'. You can
                                  also configure the log level of an extension
                                  by passing extension id and log level in the
                                  following format:
                                  '${publisher}.${name}:${logLevel}'. For
                                  example: 'vscode.csharp:trace'. Can receive
                                  one or more such entries.
  -s --status                     Print process usage and diagnostics
                                  information.
  --prof-startup                  Run CPU profiler during startup.
  --disable-extensions            Disable all installed extensions. This option
                                  is not persisted and is effective only when
                                  the command opens a new window.
  --disable-extension <ext-id>    Disable the provided extension. This option
                                  is not persisted and is effective only when
                                  the command opens a new window.
  --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.
  --telemetry                     Shows all telemetry events which VS code
                                  collects.

Subcommands
  tunnel       Make the current machine accessible from vscode.dev or other
               machines through a secure tunnel



----------------------------------------------------------------

Visual Studio Code(VS Code)命令行的使用(1)
https://www.cnblogs.com/hejunlin1992/p/10891496.html



    在终端中输入如下命令,打开VS Code界面。

code

    在终端中输入如下命令,打印出 VS Code 命令行所支持的所有参数。

code --help

    在 code 命令后加上文件或者文件夹的地址,这样VS Code 就会在一个新窗口中打开这个文件或文件夹。

code .   # 表示打开当前文件夹

           如果希望使用已经打开的窗口来打开文件,可以在 code 命令后添加参数 -r来进行窗口的复用。

code -r .

    使用参数 -g <file:line[:character]> 打开文件,然后滚动到文件中某个特定的行和列。如:

code -r -g main.cpp:120

          上述命令表示打开main.cpp文件,然后自动跳转到第120行。这个命令的一个常用的方式为,当我们编译出错时,可以使用这个命令快速跳转到某个文件的某一行。
 

    使用 -d参数,并传入两个文件路径,就可以比较两个文件的内容。如:

code -r -d a.txt b.txt

上述命令表示比较a.txt和b.txt两个文件的内容。

    VS Code 命令行除了支持打开磁盘上的文件以外,也接受来自管道中的数据。这样你就可以将原本在命令行中展示的内容,实时地展示在 VS Code 里,然后在编辑器中搜索和修改。比如,你可以把当前目录下所有的文件名都展示在编辑器里,此时只需使用如下命令。

ls | code -r -

 
另外,在VS Code文件界面和终端中切换,可以使用如下快捷键:

Ctrl + `








总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录
vscode 更多
vscode命令行 更多



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1