Skip to content

Latest commit

History

14,661 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

OpenCode Vim

npm versionCIUpstream syncWebsiteBun

OpenCode fork with vim mode. Syncs with upstream releases.

Installation

# curl
curl -fsSL https://raw.githubusercontent.com/leohenon/opencode-vim/ocv/install.sh | sh
# Package managers
npm i -g @leohenon/ocv
brew install leohenon/tap/ocv
# Arch Linux AUR (community-maintained)
yay -S opencode-vim-bin

Curl installs to ~/.ocv/bin. Set OCV_INSTALL_DIR to install elsewhere.

Usage

ocv

Update

# built-in updater
ocv update
# Package managers
npm i -g @leohenon/ocv@latest
brew upgrade ocv

Features

Vim motions

Toggle via command palette > Toggle vim mode.

Unicode word boundaries are not supported.

CategoryKeys
Character / wordh, j, k, l, w, b, e, W, B, E
Line / buffer0, ^, _, $, gg, G
Matching / paragraph%, {, }
Find / tillf, F, t, T, ;, ,
ScrollCtrl+e, Ctrl+y, Ctrl+d, Ctrl+u, Ctrl+f, Ctrl+b
Insert / replacei, I, a, A, o, O, R
Character / line editr, x, ~, s, S, J, C, dd, cc
Word changescw, cb, ciw, caw, ciW, caW
Word deletesdw, db, diw, daw, diW, daW
Quote changesci", ca", ci', ca', ci` , ca`
Quote deletesdi", da", di', da', di` , da`
Bracket changesci(, ca(, ci[, ca[, ci{, ca{, ci<, ca<
Bracket deletesdi(, da(, di[, da[, di{, da{, di<, da<
Find / till operatorscf, cF, ct, cT, df, dF, dt, dT
Matching / paragraph operatorsc%, d%, c}, c{, d}, d{
Line / word yanksyy, yw, yiw, yaw, yiW, yaW
Quote yanksyi", ya", yi', ya', yi` , ya`
Bracket yanksyi(, ya(, yi[, ya[, yi{, ya{, yi<, ya<
Matching / paragraph yanksy%, y}, y{
Put / undo / repeatp, P, u, Ctrl+r, .
Visual selectionv, V

Numeric count prefixes are supported for motions and common operators.

Note

<leader>y copies the prompt selection when present; configure it with keybinds.prompt_copy_selection. For clipboard sync, see System clipboard register.

Copy Mode

Text selection from the chat session view.

Copy mode collapses code diffs into a single column for easy copying.

KeysAction
<leader>v, Ctrl+W kEnter copy mode
h, j, k, l, arrow keysNavigate
v, V, Ctrl+VStart character-wise, line-wise, or block selection
y, yyYank to the vim register
EnterCopy to the system clipboard
YYank to the vim register and scroll to the bottom
Shift+EnterCopy to the system clipboard and scroll to the bottom
EscapeExit visual mode
qExit copy mode and scroll to the bottom
Ctrl+W jExit copy mode without scrolling
Ctrl+W wToggle copy mode
iFocus the prompt input in insert mode without scrolling
z, zt, zz, zbAdjust copy-mode scroll positioning
H, M, LJump to the top, middle, or bottom of the viewport
/, ?Search forward or backward in chat history
n, NRepeat search in the same or opposite direction

When in search mode, Enter submits the search, and Escape clears search highlights before exiting copy mode.

Search uses smartcase, lowercase queries are case-insensitive, and queries containing uppercase letters are case-sensitive.

Tip

Configure the copy mode entry key with keybinds.copy_mode.

Minimal UI

Hides extra UI hints and tips.

Toggle via command palette > Toggle minimal ui.

Configuration

Prompt input height

Configure prompt input height in tui.json:

{
"prompt_max_height": 35,
"prompt_scrollbar": true
}

prompt_max_height above 40 is not recommended.

Submit behavior

By default, insert mode uses Enter for newlines and normal mode uses Enter to submit.

To submit from insert mode too:

{
"vim_enter_submit": true
}

To always default to insert mode after a prompt submission:

{
"vim_insert_after_submit": true
}

To keep newline available:

{
"keybinds": {
"input_newline": "alt+return"
}
}

Or configure a separate submit key:

{
"keybinds": {
"input_force_submit": "alt+return"
}
}

input_force_submit is unbound by default.

System clipboard register

Use the system clipboard as Vim's register:

{
"vim_system_clipboard_register": true
}

Yank and delete operations sync to the system clipboard, p / P paste from it.

Note

Terminal/OS clipboard shortcuts don’t preserve Vim linewise register state. External clipboard text is pasted as characterwise text.

Vim langmap

Map non-English keyboard layout characters to Vim command keys.

Keys and values should be single characters.

{
"vim_langmap": {
"р": "h",
"о": "j",
"л": "k",
"д": "l"
}
}

Neovim integration

Compatible with opencode.nvim. Use the following server config:

localocv_cmd="bash -c 'exec -a opencode ocv --port'"vim.g.opencode_opts= {
server= {
start=function()
require("opencode.terminal").open(ocv_cmd)
end,
toggle=function()
require("opencode.terminal").toggle(ocv_cmd)
end,
},
}

Contributors

Thanks to everyone who contributed.

About

The open source coding agent with vim mode.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages