文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)

这是windows独有的功能吗?


当前回答

你可以使用Visual Studio Code定义的vscode:协议:

open vscode://file/full/path/to/project/or/file

你也可以使用

/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code

如果你不想修改你的路径

其他回答

将此添加到/usr/local/bin/code,如果它们不同,您可能需要修改路径。

#!/usr/bin/env bash

CONTENTS="/Applications/Visual Studio Code.app/Contents"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

之后制作可执行文件

sudo chmod +x /usr/local/bin/code

对于我来说,在Macbook Book Pro 2019 MacOS版本10.15.6上,在VSCode中打开命令面板的快捷方式是Shift + command + P。

打开它,你只需要写安装代码,然后按enter键。

之后,只需打开终端,输入代码,你的vscode将开始打开。

从Visual Studio代码设置页面:

Tip: If you want to run VS Code from the terminal by simply typing 'code', VS Code has a command, Shell Command: Install 'code' command in PATH, to add 'code' to your $PATH variable list. After installation, launch VS Code. Now open the Command Palette (F1 or ⇧+⌘+P on Mac) and type shell command to find the Shell Command: Install 'code' command in PATH command. After executing the command, restart the terminal for the new $PATH value to take effect. You'll be able to simply type 'code .' in any folder to start editing files in that folder.

我有这个问题是因为VS Code内部人员。 路径变量在那里,但我需要重命名代码内部人员。CMD里面的代码。cmd。

也许这对某些人有用。

如果你想在你的终端上打开Visual Studio Code上的文件或文件夹,下面的iTerm等命令是你安装Visual Studio Code时默认使用的命令

从命令行打开Visual Studio Code

code --

打开整个文件夹/目录

code .

打开特定的文件

code file_name
eg:- code index.html