文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
当前回答
我们将脚本更新为以下语法,以支持多个文件和文件夹作为参数,并修复了无法正确检测当前工作目录的问题:
code () {
VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
}
VS Code 1.0版本更新:
请从命令面板(查看|命令面板)使用命令在路径中安装“代码”命令或在路径中安装“代码内部人员”命令,使代码可用于命令行。
其他回答
从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.
链接你当前的文件夹到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 ."
对于我来说,在Macbook Book Pro 2019 MacOS版本10.15.6上,在VSCode中打开命令面板的快捷方式是Shift + command + P。
打开它,你只需要写安装代码,然后按enter键。
之后,只需打开终端,输入代码,你的vscode将开始打开。
这是我在这篇文章中寻找的教程。它展示了通过编写代码在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
这是我在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中打开你的当前文件夹!