Skip to main content

Setting your default editor for GitHub Codespaces

您可以在个人设置页面中设置 Codespaces 的默认编辑器。

On the settings page, you can set your editor preference so that when you create a codespace, or open an existing codespace, it is opened in your choice of:

  • Visual Studio Code (desktop application)
  • Visual Studio Code (web client application)
  • JetBrains Gateway - for opening codespaces in a JetBrains IDE
  • JupyterLab - the web interface for Project Jupyter

从模板创建新的 codespace 时,始终会在 Visual Studio Code Web 客户端中打开它。 可以在任何受支持的编辑器中重新打开现有 codespace。 有关详细信息,请参阅“打开现有 codespace”。

If you want to use Visual Studio Code as your default editor for GitHub Codespaces, you need to install Visual Studio Code and the GitHub Codespaces extension for Visual Studio Code. For more information, see the download page for Visual Studio Code and the GitHub Codespaces extension on the Visual Studio Code marketplace.

If you want to work on a codespace in a JetBrains IDE you must install the JetBrains Gateway. For more information, see "在 JetBrains IDE 中使用 GitHub Codespaces."

Setting your default editor

  1. 在任何页面的右上角,单击个人资料照片,然后单击“设置”。

    Screenshot of a user's account menu on GitHub. The menu item "Settings" is outlined in dark orange.

  2. 在边栏的“代码、规划和自动化”部分中,单击“ Codespaces”。

  3. Under "Editor preference", select the option you want.

    Screenshot of the "Editor preference" options, with "Visual Studio Code for Web" selected.

    • 如果选择“Visual Studio Code”或“JetBrains 网关”,则必须确保已在本地计算机上安装所选应用程序。

    • If you choose Visual Studio Code, GitHub Codespaces will automatically open in the desktop application when you next create or open a codespace.

      You may need to allow access to both your browser and Visual Studio Code for it to open successfully.

    • If you choose JetBrains Gateway, the Gateway application will automatically open when you next create or open a codespace.

    • If you choose JetBrains Gateway, the Gateway application will automatically open when you next create or open a codespace.

      The first time you open a codespace this way you must give permission to open the application.

      The Gateway application will open and the codespace will then be automatically selected. You can then choose a JetBrains IDE, if you have not previously done so, and click Connect to open the codespace in the JetBrains client. For more information, see "在 JetBrains IDE 中使用 GitHub Codespaces."

      To connect to a codespace from the Gateway application, you must have an SSH server running on the codespace. 连接到的 codespace 必须运行 SSH 服务器。 默认容器映像包含一个可自动启动的 SSH 服务器。 如果未通过默认映像创建 codespace,可以通过将以下内容添加到 devcontainer.json 文件中的 features 对象来安装和启动 SSH 服务器。

      "features": {
          // ...
          "ghcr.io/devcontainers/features/sshd:1": {
              "version": "latest"
          },
          // ...
      }
      
    • If you choose JupyterLab, the JupyterLab application must be installed in the codespaces you open. 默认容器映像包括 JupyterLab,因此从默认映像创建的 codespaces 将始终安装 JupyterLab。 有关默认映像的详细信息,请参阅“开发容器简介”和 devcontainers/images 存储库。 如果未在开发容器配置中使用默认映像,则可以通过将 ghcr.io/devcontainers/features/python 功能添加到 devcontainer.json 文件来安装 JupyterLab。 应该包括选项 "installJupyterlab": true。 有关详细信息,请参阅 devcontainers/features 存储库中的 python 功能自述文件

Further reading