A plugin for OpenCode TUI v2 only (V1 is completely unsupported). It does exactly one thing: adds a boolean setting named Multiple Lines (on/off, OpenCode TUI uses on/off for on/off).
- Off (default): keeps OpenCode's default behavior — in the chat input,
Entersends; newlines useShift+Enter/Ctrl+Enter/Alt+Enter/Ctrl+J. - On:
Enterinserts a newline; the original newline keys (Shift+Enter/Ctrl+Enter/Alt+Enter/Ctrl+J) send the prompt.
The setting is persistent (survives restarts, synced across TUI instances) and only affects the chat input: Enter inside dialogs, autocomplete popups, queued prompts, etc. is untouched.
This package ships a TUI entrypoint (./tui) plus a no-op server entrypoint (. / ./server) so that opencode plugin add can install it; it only supports OpenCode v2 (engines.opencode requires >=2.0.0). V1 silently ignores it.
opencode plugin add @sandlada/opencode-multiplelinesThis automatically writes the package into the global plugins array of ~/.config/opencode/cli.json (TUI-only plugins belong in cli.json, not opencode.json(c)) and installs dependencies.
Edit ~/.config/opencode/cli.json directly:
{
"$schema": "https://opencode.ai/v2/cli.json",
"plugins": ["E:\\projects\\sandlada\\opencode-multiplelines"]
}Or override temporarily with OPENCODE_CLI_CONFIG_CONTENT:
OPENCODE_CLI_CONFIG_CONTENT='{"plugins":["E:\\projects\\sandlada\\opencode-multiplelines"]}' opencodeOpen the Multiple Lines setting, two ways:
- Press
Ctrl+P, run the Multiple Lines command, then pickon/offin the dialog; - Type a slash command in the input:
/multiple-lines— opens the dialog above;/multiple-lines on— turn on;/multiple-lines off— turn off;/multiple-lines toggle— flip directly.
Each change shows a Multiple Lines: on/off toast. The current value is stored in plugin storage (settings), default off.
You can also seed the initial value via plugin options in cli.json (only the first time, when no storage file exists; afterward storage wins):
{
"plugins": [
{
"package": "@sandlada/opencode-multiplelines",
"options": { "multipleLines": true }
}
]
}Two keymap layers are registered:
globalcommand layer: provides the setting command above;baseswap layer (priority: 100, above the host managed-textarea layer's default0),enabledbound to the setting:- When on,
returndispatchesinput.newline;shift+return/ctrl+return/alt+return/ctrl+jdispatchinput.submit; - The
runchecks that the focused editor is a multilineTextarea(excludes single-lineInput); otherwise it returnsfalseso the keystroke continues to its normal handler; - The swap layer only activates in
basemode;modal/autocompletemodes keep their own bindings, so dialogEnteris never mis-swapped.
- When on,
Note: this plugin targets OpenCode v2's default keybinds (
input.submit=return,input.newline=shift+return,ctrl+return,alt+return,ctrl+j). If you override those two keybinds incli.json, the plugin still intercepts the default keys listed above; adapt the extra keys in your own keybind config.
pnpm install
pnpm typecheck # tsc --noEmit
pnpm test # bun test (pure-logic + mock-context integration tests)
pnpm run pack:dry-runCoverage: setting title, on/off parsing, slash-command input, options initial value, multiline-vs-single-line focus, on/off swap behavior and fallback.
package.json # npm plugin manifest (exports "./tui", v2 only)
src/tui.ts # plugin entry (Plugin.define)
src/settings.ts # pure logic (title, key names, parsing, fallback detection)
test/*.test.ts # Bun tests
{ "$schema": "https://opencode.ai/v2/cli.json", "plugins": ["@sandlada/opencode-multiplelines"] }