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

这是windows独有的功能吗?


当前回答

这是我在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中打开你的当前文件夹!

其他回答

我有一个~/bin/code shell脚本,它与@BengaminPasero写的命令相匹配。

#!/bin/bash
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*

我把~/bin:前缀到我的$PATH,这允许我在不污染~/的情况下添加一堆一次性脚本。bash_profile脚本。

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

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

你也可以使用

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

如果你不想修改你的路径

这是我在这篇文章中寻找的教程。它展示了通过编写代码在Visual Studio Code中打开文件的方法。

1.-打开文件

Bash

                open ~/.bash_profile 

终端OS

                    open ~/.zshrc

2.-在你的文件中添加:

         code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

3.-重新设置终端,并尝试在你想打开的文件夹

         code .

4.-那么你可以像下面的评论那样使用它:https://stackoverflow.com/a/41821250/10033560

链接你当前的文件夹到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 ."

试试这个

打开Visual Studio Code,按Command + Shift + P,然后在命令面板中输入Shell,现在你可以找到这个选项,比如Shell命令:从命令面板中的建议列表中安装代码。选择该选项。

通过终端/命令提示打开VSCode

就是这样。

现在打开终端类型。

$ code。