Skip to content

Latest commit

 

History

History
213 lines (156 loc) · 7.77 KB

File metadata and controls

213 lines (156 loc) · 7.77 KB

OpenCode Vim

npm version CI Last commit Bun Website

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

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.

Category Keys
Character / word h, j, k, l, w, b, e, W, B, E
Line / buffer 0, ^, _, $, gg, G
Matching / paragraph %, {, }
Find / till f, F, t, T, ;, ,
Scroll Ctrl+e, Ctrl+y, Ctrl+d, Ctrl+u, Ctrl+f, Ctrl+b
Insert / replace i, I, a, A, o, O, R
Character / line edit r, x, ~, s, S, J, C, dd, cc
Word changes cw, cb, ciw, caw, ciW, caW
Word deletes dw, db, diw, daw, diW, daW
Quote changes ci", ca", ci', ca', ci` , ca`
Quote deletes di", da", di', da', di` , da`
Bracket changes ci(, ca(, ci[, ca[, ci{, ca{, ci<, ca<
Bracket deletes di(, da(, di[, da[, di{, da{, di<, da<
Find / till operators cf, cF, ct, cT, df, dF, dt, dT
Matching / paragraph operators c%, d%, c}, c{, d}, d{
Line / word yanks yy, yw, yiw, yaw, yiW, yaW
Quote yanks yi", ya", yi', ya', yi` , ya`
Bracket yanks yi(, ya(, yi[, ya[, yi{, ya{, yi<, ya<
Matching / paragraph yanks y%, y}, y{
Put / undo / repeat p, P, u, Ctrl+r, .
Visual selection v, V

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.

Keys Action
<leader>v, Ctrl+W k Enter copy mode
h, j, k, l, arrow keys Navigate
v, V Start character-wise or line-wise selection
y, yy Yank to the vim register
Enter Copy to the system clipboard
Y Yank to the vim register and scroll to the bottom
Shift+Enter Copy to the system clipboard and scroll to the bottom
Escape Exit visual mode
q Exit copy mode and scroll to the bottom
Ctrl+W j Exit copy mode without scrolling
Ctrl+W w Toggle copy mode
i Focus the prompt input in insert mode without scrolling
z, zt, zz, zb Adjust copy-mode scroll positioning
H, M, L Jump to the top, middle, or bottom of the viewport

Tip

Configure the 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 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:

local ocv_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.