如何安装 VSCode 扩展
VSCode 扩展
![](/data/attachment/album/202210/02/232225yzgzrymdrepj2mpa.jpg)



> 
> 通过图形界面和命令行两种方法，了解如何在 VSCode 中搜索和安装扩展。
> 
> 
> 


微软的 [Visual Studio Code](https://code.visualstudio.com/)（VSCode）可能是最流行的 [开源代码编辑器](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/)，仅次于 Vim（当然）。


VSCode 通过提供几乎所有类似 IDE 的功能，提供了令人惊叹的“开箱即用”体验。 但总有一些事情是你希望 VSCode 能够另外做到的。*正所谓“邻家芳草绿，隔岸风景好”* : )


你可以在 Visual Studio Code <ruby> <a href="https://marketplace.visualstudio.com/VSCode">  市场 </a> <rt>  Marketplace </rt></ruby> 找到 VSCode 扩展插件。在 VSCode 市场上发布的扩展插件在发布之前会进行病毒扫描，所以这些扩展可以 [信任](https://code.visualstudio.com/docs/editor/extension-marketplace#_can-i-trust-extensions-from-the-marketplace)。


### 在 VSCode 中安装扩展插件


你不需要访问 VSCode <ruby> 市场 <rt>  Marketplace </rt></ruby> 网站就可以安装扩展插件。也就是说，你可以直接从 VSCode 本身安装和管理扩展插件。


我希望你已经在你使用的操作系统（比如 [在 Linux](https://itsfoss.com/install-visual-studio-code-ubuntu/)）上 安装了 VSCode。


打开 VSCode，最左侧是活动栏。活动栏上的最后一个按钮就是“扩展”按钮。点击它之后你会看到大量可安装的扩展。


![访问 VSCode 中的扩展选项卡](/data/attachment/album/202210/02/232228n1h38y1hhh1183zf.jpg)


你也可以按快捷键组合 `Ctrl + Shift + X` 来启动扩展栏的侧面面板。


如果你还没有安装任何扩展的话，你会看到 VSCode 市场上最流行的扩展列表。


#### 找到并安装某个扩展（图形界面方法）


现在是时候尝试一下 Linux 人谈论的 `vim` 了（鼓动的语气）; )


开玩笑啦。让我们安装一些对我们初学者更友好，可以轻松使用而且无需太多练习的扩展吧。


从最流行的扩展列表中单击 “Visual Studio IntelliCode” （①）扩展。


![如何安装 Visual Studio IntelliCode 等扩展](/data/attachment/album/202210/02/232228cadk6txpkdd5zvvk.jpg)


点击 “<ruby> 安装 <rt>  Install </rt></ruby>” 按钮（②）即可安装 “Visual Studio IntelliCode” 扩展。这个扩展会在你编写代码时为你提供 AI 预测的建议。


安装后，你可以充分利用此扩展。试试用你喜欢的编程语言输入一段代码，然后看看 AI 的自动完成功能是否顺利运行而且没有拖慢你的工作进程。


![在 Visual Studio Code 中管理已安装的扩展](/data/attachment/album/202210/02/232229opm6i4jripfjmk40.jpg)


如果你不喜欢某个已安装的扩展插件，你只需单击 “<ruby> 卸载 <rt>  Uninstall </rt></ruby>” 按钮（②）即可完全删除不需要的扩展插件。


如果你安装了多个扩展插件，并且你觉得其中某个扩展插件给你带来了问题——比如说突然崩溃；你只需点击 “<ruby> 禁用 <rt>  Disable </rt></ruby>” 按钮（①）即可禁用一个（或多个）扩展插件，并检查扩展插件 *甲* 是否在起作用，或者它是扩展插件 *乙*，还是完全不同的东西。


考虑到扩展删除和重新安装需要很长时间，当你安装了多个扩展时，禁用扩展会很方便。


#### 另外方法：使用终端安装扩展


你知道你可以从终端安装 VSCode 扩展吗？不过，现在你知道了！


要从你的终端安装扩展程序，你需要知道扩展程序名称和发布者名称，再按照 `发布者名称.扩展程序名称` 的顺序找到它。比如说，如果你想安装 “Visual Studio IntelliCode” 这个扩展（前面提到的），它的名称就是 `VisualStudioExptTeam.vscodeintellicode`。


要找出扩展用于标识的唯一名称（ID），首先要在你的浏览器中 [访问 VSCode 市场](https://marketplace.visualstudio.com/)。


![VSCode 市场的截图](/data/attachment/album/202210/02/232230t3jw8gawzabxbgx8.jpg)


然后搜索某个扩展，在本教程中，我将以安装 “Visual Studio IntelliCode” 这个扩展为例。下一步，打开你要安装的扩展程序的页面。


![搜索Visual Studio IntelliCode并打开扩展网页](/data/attachment/album/202210/02/232230uoo84pccooebcu4u.jpg)


打开扩展程序的网页后，你将看到一个代码块。下面的截图突出标示了扩展程序的 ID。


![VSCode 扩展的 ID](/data/attachment/album/202210/02/232231kiv6n3ulv082n432.jpg)


一旦你有了想要安装的扩展的 ID —— 在这种情况下是 `VisualStudioExptTeam.vscodeintellicode`，你可以通过在终端中运行以下命令来继续。



```
code --install-extension VisualStudioExptTeam.vscodeintellicode

```

与图形界面一样，命令行界面也允许你安装、禁用、删除和管理扩展。


可以通过运行以下命令查看已安装的所有扩展的列表。



```
code --list-extensions

```

要禁用单个扩展，请运行以下命令：



```
code --disable-extension <在这里输入扩展的ID>

```

如果要禁用所有扩展，可以运行以下命令：



```
code --disable-extensions

```

上述命令将禁用 **所有** 已安装的扩展。这将帮助你判断导致问题的是插件，还是 VSCode 本身。


现在，如果你想完全删除任何某个扩展，请运行以下命令：



```
code --uninstall-extension <在这里输入扩展的ID>

```

### 总结


我发现使用 VSCode 安装扩展要容易得多。毕竟，它直接在我编辑器左边的侧栏中。


一旦你对 VSCode 的操作得心应手，也许可以看看这篇文章，[VSCode 实用快捷键](https://itsfoss.com/vs-code-shortcuts/) 可能会帮助你提高工作效率！


写代码顺利，新朋友！ : )




---


via: <https://itsfoss.com/install-vs-code-extensions/>


作者：[Pratham Patel](https://itsfoss.com/author/pratham/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[泠知落汐](https://github.com/CoWave-Fall) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
*Brief: Learn how to search for extensions and install them in Visual Studio Code editor. Both GUI and command line methods have been discussed.*

Microsoft’s [Visual Studio Code](https://code.visualstudio.com/) is perhaps the most popular [open source code editor](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/), after Vim (of course).

Visual Studio Code provides an amazing “out of the box” experience by providing almost all of the IDE like features. But there are always things you wish Visual Studio Code could do. *“The grass is always greener on the other side.”*

The [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/VSCode) is exactly where you will find the extensions for Visual Studio Code. Extensions that are published on the Visual Studio Code Marketplace are scanned for viruses before they are published. So these extensions can be [trusted](https://code.visualstudio.com/docs/editor/extension-marketplace#_can-i-trust-extensions-from-the-marketplace).

## Installing extensions in Visual Studio Code

You don’t need to go to the Marketplace website for installing extensions. You can install and manage extensions right from the editor itself.

I hope you have [Visual Studio Code installed on Linux](https://itsfoss.com/install-visual-studio-code-ubuntu/) or whichever operating system you are using.

Open Visual Studio Code, and to the left most side, is the Activity Bar. The last button on the Activity Bar is the Extensions button. Clicking on that will expose you to the enormous wealth of the extensions available for installation on Visual Studio Code.

![01 all extensions 1](https://itsfoss.com/content/images/wordpress/2021/10/01-all-extensions-1-800x450.webp)

*You can also press the Shortcut Key combination Ctrl + Shift + X to launch the Extensions side pane.*

If you do not have any extensions installed, you will see a list of the most popular extensions available on the Visual Studio Code Marketplace. There are extensions you wish Visual Studio Code already had. And then, some day you will discover an extension and wonder how you lived without it!

### Find an extension and install it from the editor (GUI method)

Now is the time to try out that `vim`

thing Linux people talk about *nudge nudge* ;)

Just kidding. Let us install something more beginner friendly and something that a beginner can easily take advantage of, without much practice.

Click on **Visual Studio IntelliCode** (#1) extension from the list presented of the most popular extensions.

![02 select intellicode 1](https://itsfoss.com/content/images/wordpress/2021/10/02-select-intellicode-1-800x450.webp)

Simply clicking on the **Install** button (#2) will install the **Visual Studio IntelliCode** extension. This extension gives you AI-predicted suggestions while you are writing code.

Once installed, you will be able to take full advantage of this extension. Try typing a block of code in your preferred programming language and check if the suggested AI autocomplete is working out for you, and not causing any kind of slowdown in your workflow.

![03 intellicode installation done 1](https://itsfoss.com/content/images/wordpress/2021/10/03-intellicode-installation-done-1-800x450.webp)

If you dislike any of the installed extension, you can simply click on the **Uninstall** button (#2) to completely remove the unwanted extension.

If you have multiple extensions installed, and if you feel like one of the installed extensions is causing you problems – say like sudden crashes; You can simply disable one (or multiple) extension(s) simply by clicking on the **Disable** button (#1) and check if extension *x* was acting up or was it extension *y*, or was it something different altogether.

Considering that extension removal and re-installation takes a long time, disabling extensions can be handy when you have multiple extensions installed.

### Alternate method: Install extensions using the terminal

Did you know you could install a Visual Studio Code extension from the terminal itself? Well, now you do!

To install an extension from your terminal, you need to know the extension name and publisher name in the order of `publisher.extension`

. For an example, if you want to install the same extension as you did before, Visual Studio IntelliCode, it’s publisher name and extension name is `VisualStudioExptTeam.vscodeintellicode`

.

To find out this unique identifier of any extension, firstly, [visit the Visual Studio Code Marketplace](https://marketplace.visualstudio.com/) in your browser of choice.

![visual studio code marketplace](https://itsfoss.com/content/images/wordpress/2021/10/visual_studio_code_marketplace-800x450.webp)

Then search for any extension, for this tutorial, I will focus on installing Visual Studio IntelliCode. And then open the page of the extension that you want to install.

![visual stuido code ext search](https://itsfoss.com/content/images/wordpress/2021/10/visual_stuido_code_ext_search-800x450.webp)

Once you have the web page of your extension open, you will see a code block. In the screenshot of the extension web page below is the highlighted unique identifier of the extension.

![vs code extension identifier](https://itsfoss.com/content/images/wordpress/2021/10/vs_code_extension_identifier-800x450.webp)

Once you have the unique code of the extension you desire to install – **VisualStudioExptTeam.vscodeintellicode** in this case, you can proceed by running the following command in your terminal.

`code --install-extension VisualStudioExptTeam.vscodeintellicode`


Like the GUI, the command line interface also allows you to install, disable, remove and manage extensions.

There is a handy flag that will give you a list of all the extensions you have installed. You can do that by running the following command:

`code --list-extensions`


To disable a single extension, run this command:

`code --disable-extension <YOUR-EXTENSION-ID>`


If you want to disable all extensions, you can run the following command:

`code --disable-extensions`


The above command will disable **all** installed extensions. This will help you diagnose if extensions are causing problems or is it Visual Studio Code itself.

Now, if you want to completely remove any extension, use this command:

`code --uninstall-extension <YOUR-EXTENSION-ID>`


## Conclusion

I find it much easier to use the editor for installing VS Code extensions. It’s straight in the editor where I code after all.

Once you are comfortable tinkering with Visual Studio Code, maybe checkout this article pointing out some [useful keyboard shortcuts for Visual Studio Code](https://itsfoss.com/vs-code-shortcuts/) that might help you get even more productive!

Happy coding, fellow *nix user! :)