文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
当前回答
对于Windows,您可以使用命令:
start Code filename.extension
上面这句话对我很适用。
其他回答
从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.
我把这个添加到我的~/.profile中
alias vscode='/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'
then
. ~/.profile
之后我就可以做了
vscode
从终点站
如果你正在使用可视代码内部,并且你想从你的终端或任何其他命令行工具在visual Studio code内部打开一个文件或文件夹,那么你可以参考下面的命令,这些命令在visual Studio code内部默认出现。
从命令行打开Visual Studio Code
code-insiders——
打开整个文件夹/目录
code-insiders。
打开特定的文件
code-insiders file_name
例:- code index.html
这是我在这篇文章中寻找的教程。它展示了通过编写代码在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
在我的情况下,我必须使用一个别名:
alias code="/<PATH TO VSCODE>/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"
您可以在~/.bash_profile中添加这个别名。