75 lines
3.4 KiB
Markdown
75 lines
3.4 KiB
Markdown
|
|
# 安装 VSCode:如何在 Windows、Linux 和 MacOS 上安装和运行
|
|||
|
|
|
|||
|
|
> 原文:[https://python . land/creating-python-programs/installing-and-starting-vs code](https://python.land/creating-python-programs/installing-and-starting-vscode)
|
|||
|
|
|
|||
|
|
现在你知道了[为什么 VSCode 很棒](https://python.land/creating-python-programs/using-a-python-ide),为什么它可能也是你的最佳选择。你可能等不及要安装 VSCode 了吧?我们将探索安装 VSCode 的不同方法以及如何启动它。
|
|||
|
|
|
|||
|
|
目录
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
* [安装 VSCode](#Installing_VSCode "Installing VSCode")
|
|||
|
|
* [启动 VSCode](#Starting_VSCode "Starting VSCode")
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 安装 VSCode
|
|||
|
|
|
|||
|
|
就像[安装 Python](https://python.land/installing-python) 的时候一样,安装 VSCode 有很多种方法。
|
|||
|
|
|
|||
|
|
### 从官方网站下载
|
|||
|
|
|
|||
|
|
VSCode 可以从[这个网站](https://code.visualstudio.com/)免费下载。它适用于以下平台:
|
|||
|
|
|
|||
|
|
* Windows 操作系统
|
|||
|
|
* Linux 操作系统
|
|||
|
|
* 苹果
|
|||
|
|
|
|||
|
|
确保为您的平台下载正确的二进制文件。该网站试图自动检测你的平台,并提供正确的链接,所以这应该不会太难!下载后,打开文件并按照步骤将其安装到您的系统上。
|
|||
|
|
|
|||
|
|
### 使用特定于操作系统的软件包管理器
|
|||
|
|
|
|||
|
|
在 Linux 和 MacOS 上,您可以使用好的替代方法来安装 VSCode。例如,如果您是自制软件用户,您可以安装 [vscode 桶](https://formulae.brew.sh/cask/visual-studio-code),其中包括:
|
|||
|
|
|
|||
|
|
`$ brew install --cask visual-studio-code`
|
|||
|
|
|
|||
|
|
Thank you for reading my tutorials. I write these in my free time, and it requires a lot of time and effort. I use ads to keep writing these *free* articles, I hope you understand! **Support me by disabling your adblocker on my website** or, alternatively, **[buy me some coffee](https://www.buymeacoffee.com/pythonland)**. It's much appreciated and allows me to keep working on this site!
|
|||
|
|
|
|||
|
|
如果你用的是 Ubuntu,你可能想用 snap 来代替。所有这些方法都很好,甚至可能比手动下载 VSCode 更好。我个人在 Ubuntu 上使用 snap 包,它运行得非常完美,并且保持最新版本。
|
|||
|
|
|
|||
|
|
### VS 法典
|
|||
|
|
|
|||
|
|
虽然 VSCode 是免费的,但有些人担心,因为它是由微软构建和维护的。据我所知,代码是开源的,但二进制版本不是。微软采用开源软件,并添加了一些额外的东西,比如品牌和遥测技术(你可以把这个关掉)。
|
|||
|
|
|
|||
|
|
如果你是一个开源纯粹主义者,有一个由社区构建的二进制发行版,叫做 [vscodium](https://vscodium.com/) 。我没有亲自尝试过,但它应该和官方发布的完全一样。绝对明确:VSCode 本身是免费的。就我个人而言,我对微软构建二进制文件很满意,甚至不太介意遥测,尽管我通常在安装新操作系统时会关闭它。
|
|||
|
|
|
|||
|
|
## 启动 VSCode
|
|||
|
|
|
|||
|
|
有两种方法可以启动 VSCode:
|
|||
|
|
|
|||
|
|
1. 在菜单中查找并点击它
|
|||
|
|
2. 从命令行启动它
|
|||
|
|
|
|||
|
|
### 从“开始”菜单启动 VSCode
|
|||
|
|
|
|||
|
|
大多数操作系统都有菜单系统,例如:
|
|||
|
|
|
|||
|
|
1. Windows 上的开始菜单
|
|||
|
|
2. MacOS 上的启动器
|
|||
|
|
3. Linux 上类似的功能,例如 Gnome Shell。
|
|||
|
|
|
|||
|
|
如果您想打开 VSCode,只需查找并单击图标。
|
|||
|
|
|
|||
|
|
### 从命令行启动 VSCode
|
|||
|
|
|
|||
|
|
从命令行启动 VSCode 的一大好处是,可以直接传递路径或文件来打开它。在所有平台上,您都可以在 VSCode 中将当前目录作为项目打开,只需键入:
|
|||
|
|
|
|||
|
|
```py
|
|||
|
|
$ code .
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
您也可以使用`code`命令打开特定文件:
|
|||
|
|
|
|||
|
|
```py
|
|||
|
|
$ code myscript.py
|
|||
|
|
```
|