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

这是windows独有的功能吗?


当前回答

从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,你需要将vs code移动到应用程序文件夹,然后打开vs code,然后按shift + command + p,你会看到下图。然后你需要输入代码。现在可以开始了。

如果你使用snap安装VS CODE。您需要在PATH环境变量中添加/snap/bin。 打开。bashrc或。zshrc 并在PATH环境变量中添加/snap/bin

重新加载终端, 代码命令将启动它

运行代码的步骤。命令启动VSCode应用程序-

打开VSCode 打开命令托盘(Cmd+Shift+P) 输入Shell命令:在PATH中安装'code'命令并选择 你会得到Shell命令'code'成功安装在PATH的通知。 重新启动终端并输入代码。 这将从其中的当前文件夹文件打开VSCode。

我发现了mingw32的一个巧妙的解决方法(即对于那些使用git-scm.com在windows上安装的bash版本的人来说):

code () { VSCODE_CWD="$PWD" cmd //c code $* ;}

windows用户 只要输入

>code .

这里有更多命令 https://code.visualstudio.com/docs/editor/command-line