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

这是windows独有的功能吗?


当前回答

我运行:open -a "Visual Studio Code" [folder-name]用我的Visual Studio Code应用程序打开一个文件夹。如果您只是想打开应用程序,文件夹名称是可选的。不确定这是否是您的用例,但希望这对您有所帮助!

其他回答

windows用户 只要输入

>code .

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

只要更新你的python到python3.9,我这样做了,它为我工作。

链接你当前的文件夹到vscode。

Windows Registry Editor Version 5.00

; Directory\Background\shell => on empty space

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
@="VsCode"

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="C:\\current-folder-vscode\\Code.exe ."

; Directory\shell => on a folder

[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="VsCode"
"Icon"="C:\\current-folder-vscode\\Code.exe,0"

[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="C:\\current-folder-vscode\\Code.exe ."

将此添加到/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

这是我在Mac OS Catalina上的工作方式——在这里找到(谢谢,Josiah!)

如果你在Mac OS Catalina上,你需要编辑你的.zprofile而不是.bash_profile。

编辑~/。Zprofile文件:vim ~/.zprofile 在它自己的行中添加以下代码:code () {VSCODE_CWD="$PWD" open -n -b "com.microsoft。——args $*;} 保存文件::wq 重新运行更新的文件:source ~/.zprofile。 测试运行的代码。在VS Code中打开你的当前文件夹!