Skip to main content

IDE Integration

opencode integrates with your editor and IDE through several mechanisms -- from the $EDITOR environment variable for prompt composition, to LSP for code intelligence, to plugins for deeper integration.

Editor Fundamentals

The $EDITOR Environment Variable

Many opencode features rely on the EDITOR environment variable:

  • /editor command -- opens your current message in $EDITOR for composing complex prompts
  • /export command -- opens the session transcript in $EDITOR for saving

Set EDITOR in your shell profile:

export EDITOR="code --wait" # VS Code
export EDITOR="cursor --wait" # Cursor
export EDITOR="windsurf --wait" # Windsurf
export EDITOR="nvim" # Neovim
export EDITOR="vim" # Vim
export EDITOR="nano" # Nano
export EDITOR="subl -n -w" # Sublime Text

Terminal Editors

Terminal-based editors work without the --wait flag because they run in the foreground by nature:

  • Neovim (nvim) -- modern Vim fork with LSP support
  • Vim (vim) -- classic modal editor
  • Nano (nano) -- simple, beginner-friendly editor
  • Helix (hx) -- modern modal editor with built-in LSP
  • Kakoune (kak) -- modal editor with multiple selections
  • Emacs (emacs -nw) -- terminal Emacs (non-windowed)
  • Micro (micro) -- modern terminal editor with familiar keybinds
tip

Pair opencode with tmux for a powerful terminal-based IDE workflow with split panes.

VS Code

CLI Workflow

Use VS Code as your $EDITOR:

export EDITOR="code --wait"

Now when you run /editor in opencode's TUI, VS Code opens with your prompt text. Write your prompt, save the file, close the tab, and opencode sends the content.

Inline Code Assistance

While working in VS Code, you can:

  1. Keep opencode running in a split terminal (Ctrl+`)
  2. Use @ file references to bring editor files into context
  3. Use ! commands to run VS Code terminal tasks
  4. View diffs from opencode's changes in VS Code's source control panel

VS Code Extension

The opencode VS Code extension provides deeper integration:

  • Chat panel within VS Code
  • Inline code suggestions
  • File-level operations from the editor context menu
  • Direct access to opencode commands

Install it from the VS Code Marketplace.

Cursor

Cursor is an AI-first IDE built on VS Code. Use it with opencode:

export EDITOR="cursor --wait"

Cursor's AI features and opencode can complement each other:

  • Use Cursor's inline editing for quick changes
  • Use opencode for complex, multi-file tasks
  • Reference Cursor's AI output in opencode conversations

Windsurf

Windsurf is another AI-native IDE. Integration:

export EDITOR="windsurf --wait"

Neovim

Neovim integrates naturally with opencode since both run in the terminal.

Basic Setup

export EDITOR="nvim"

Split Layout

Run opencode and Neovim side by side using tmux:

# In tmux
tmux split-window -h
# Left pane: nvim
# Right pane: opencode

Neovim Plugin

For deeper integration, consider using the opencode Neovim plugin (if available) or the generic plugin system described below.

Tmux Integration

tmux pairs exceptionally well with opencode:

# Create a session with opencode
tmux new-session -s opencode 'opencode'

# Split vertically for editor
tmux split-window -h 'nvim'

# Create a dedicated window for shell commands
tmux new-window 'bash'

Attach opencode to specific tmux panes for ! command execution:

{
"tools": {
"bash": {
"tmux": {
"session": "opencode",
"window": "shell",
"pane": 0
}
}
}
}

What's Next