OpenCode 可以与 VS Code、Cursor 或任何支持终端的 IDE 集成。只需在终端中运行 opencode 即可开始使用。
使用方式(Usage)
快速启动(Quick Launch)
- Mac:按
Cmd+Esc - Windows / Linux:按
Ctrl+Esc打开一个分屏终端中的 OpenCode,或者如果已经有正在运行的终端会话,则直接聚焦到该会话。
- Mac:按
新建会话(New Session)
- Mac:按
Cmd+Shift+Esc - Windows / Linux:按
Ctrl+Shift+Esc即使当前已经有一个 OpenCode 会话,也可以启动一个新的终端会话。你也可以点击 UI 中的 OpenCode 按钮。
- Mac:按
上下文感知(Context Awareness) 会自动把你当前选中的代码或当前打开的 Tab 共享给 OpenCode,方便模型理解上下文。
文件引用快捷键(File Reference Shortcuts)
- Mac:
Cmd+Option+K - Linux / Windows:
Alt+Ctrl+K可以快速插入文件引用,例如:@File#L37-42,表示引用某个文件的第 37–42 行。
- Mac:
安装(Installation)
在 VS Code 及其常见分支版本(Cursor、Windsurf、VSCodium) 中安装 OpenCode:
- 打开 VS Code
- 打开集成终端(Integrated Terminal)
- 运行
opencode—— 扩展会自动安装
如果你希望在 TUI 中使用 /editor 或 /export 时打开的是你自己的 IDE,需要设置环境变量:
export EDITOR="code --wait"
更多说明可参考:/docs/tui/#editor-setup。
手动安装(Manual Install)
在 Extension Marketplace 中搜索 OpenCode,然后点击 Install 即可。
故障排查(Troubleshooting)
如果扩展没有自动安装,请检查:
- 确认你是在 集成终端(integrated terminal) 中运行
opencode。 确认你的 IDE 的 CLI 命令已经安装:
- VS Code:
code - Cursor:
cursor - Windsurf:
windsurf - VSCodium:
codium
- VS Code:
如果没有安装:
- Mac:按
Cmd+Shift+P - Windows / Linux:按
Ctrl+Shift+P - 搜索并执行: “Shell Command: Install ‘code’ command in PATH”(或对应 IDE 的等效命令)
- Mac:按
- 确认 VS Code 具有安装扩展的权限。
