Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VS Code Install OpenCode

VS Code Install OpenCode

If you don't like using OpenCode's command-line model, we can install OpenCode in the VS Code editor.

Open VS Code, go to the Extensions marketplace, and search for OpenCode Installation:

After installation, click the OpenCode icon in the upper right corner to enter the OpenCode page:

The entire interface is shown below:


Other notes

OpenCode can not only run independently in the terminal, but also be integrated with common development tools, such as VS Code, Cursor, Windsurf, VSCodium, etc.

As long as your IDE supports a terminal, you can use OpenCode.

The simplest way is: run in the IDE's built-in terminal opencode。

I. Quick start

1. Start OpenCode

After opening a project in VS Code:


opencode

to enter the OpenCode interface.

2. Quick start method (recommended)

Function Mac Windows / Linux
Quickly open OpenCode Cmd + Esc Ctrl + Esc
New OpenCode session Cmd + Shift + Esc Ctrl + Shift + Esc

Explanation:

II. Core features

1. Context awareness (very important)

OpenCode automatically obtains your current development context, for example:

This means:

2. File reference shortcuts

You can quickly insert file references via shortcuts:

System Keyboard shortcut
Mac Cmd + Option + K
Windows / Linux Ctrl + Alt + K

The insertion effect is similar to:


@File#L37-42

Indicates referencing a specified line range of a file.

III. Configure the default editor

If you want to execute in OpenCode /editor or /export using VS Code, you need to set environment variables:


export EDITOR="code --wait"

Explanation: