这个问题说明了一切。

如何打开VS Code编辑器

windows cmd Linux和MAC终端

例如,为记事本++我写

>开始记分卡+测试。txt

顺便说一下,编辑器很棒(跨平台)!谢谢你,纳德拉!

你可以从微软下载


当前回答

在mac上的其他简单方法是:进入命令面板[Shift⇧+ Command(⌘)+P],并键入:Shell命令:在PATH中安装'code'命令

Shell命令'code'成功安装在PATH中。

然后您也可以使用来自终端的代码。

其他回答

在某种程度上,我不愿在长长的答案清单上再添什么。然而,我在这个页面上搜索“便携式”这个词,却一无所获。(我做了一个完整的Stack Overflow搜索,也没有发现任何东西。)所以我想把这个非常具体的答案补充给潜在的未来搜索者。

这个答案适用于你在Windows 10的便携模式下安装VS Code。

“便携式模式”指的是在VS Code官方网页上描述的内容,截至2021年1月21日,可以在这里找到:https://code.visualstudio.com。这并不意味着由Gareth Flowers开始/运行的Visual Studio Code Portable项目,或任何类似的项目。(我并不是在说这个或其他项目的坏话——我既没有使用过也没有评估过。)如果您正在使用其中一个项目,您需要检查该项目文档/社区-尽管这可能会起作用。

在可移植模式下“安装”VS Code就是下载一个。zip文件,然后在你想要你的VS Code“安装”的任何地方提取它。没有运行实际的安装或设置,因此不会自动将code命令添加到PATH中。


回答

在将Portable Mode VS Code文件解压缩到您选择的位置后,该位置应该有一个bin文件夹。复制该bin文件夹的完整路径并将其添加到您的System或User(您选择)path变量中。

然后,您应该能够从PowerShell或CMD中使用code命令。

一种简单的方法是转到你想要打开它并键入的项目

代码。cmd D: \ PathTo \ \ MyProject的志愿者项目

就是这样。它将在Visual Studio Code中打开您的项目。

根据文档:

Mac OS X Download Visual Studio Code for Mac OS X. Double-click on VSCode-osx.zip to expand the contents. Drag Visual Studio Code.app to the Applications folder, making it available in the Launchpad. Add VS Code to your Dock by right-clicking on the icon and choosing Options, Keep in Dock. Tip: If you want to run VS Code from the terminal, append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh). code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;} Now, you can simply type code . in any folder to start editing files in that folder. Tip: You can also add it to VS Code Insiders build by changing "com.microsoft.VSCodeInsiders". Also if you don't to type the whole word code, just change it to c. Linux Download Visual Studio Code for Linux. Make a new folder and extract VSCode-linux-x64.zip inside that folder. Double click on Code to run Visual Studio Code. Tip: If you want to run VS Code from the terminal, create the following link substituting /path/to/vscode/Code with the absolute path to the Code executable sudo ln -s /path/to/vscode/Code /usr/local/bin/code Now, you can simply type code . in any folder to start editing files in that folder.

在Windows上安装时,系统会提示您将VS Code添加到PATH中。

我试图弄清楚如何从命令行用VS Code打开文件,我已经有了这个能力-我只是忘了我已经添加了它。您可能已经安装了它-通过导航到要打开的文件夹并运行命令代码进行检查。打开该文件夹。

在linux中,如果你使用代码。它将打开终端所在文件夹中的VS Code。 使用代码。文件名。cs它会在文件夹中打开该文件。