Feature Request: Vim insert mode key remapping (imap equivalent)
Feature Request: Vim Insert Mode Key Remapping in Chat Input
Problem
Currently, Claude Code supports editorMode: "vim" which enables vim keybindings in the chat input. However, the keybinding system (~/.claude/keybindings.json) cannot customize vim mode transitions, particularly mapping key sequences to escape insert mode.
Users with muscle memory from vim/neovim commonly use sequences like fd, jk, or jj as alternatives to Escape for exiting insert mode (via :imap fd <Esc> in vim). This muscle memory doesn't transfer to Claude Code.
Current Workaround Attempted
Setting a keybinding chord in ~/.claude/keybindings.json:
{
"context": "Chat",
"bindings": {
"f d": "chat:cancel"
}
}
Issues with this approach:
- Blocks normal typing of the first key ('f' waits for chord completion)
chat:cancelis not the same as "exit vim insert mode"- The keybinding system operates at a different level than vim mode
Proposed Solution
Add vim-specific configuration options, similar to neovim's :imap, :nmap, etc. For example:
Option 1: Dedicated vim section in settings.json
{
"editorMode": "vim",
"vimMappings": {
"insert": {
"fd": "<Esc>",
"jk": "<Esc>"
}
}
}
Option 2: Extend keybindings.json with vim contexts
{
"context": "Chat.VimInsert",
"bindings": {
"f d": "vim:exitInsertMode"
}
}
Use Case
As a vim user with inoremap fd <Esc> in my .vimrc/init.lua, I want the same mapping in Claude Code's chat input so I can use consistent muscle memory across all my editing environments.
Alternatives Considered
- Using native
Escapekey (works but breaks muscle memory) - System-wide key remapping tools (too broad, affects all applications)
Related
This would align Claude Code's vim mode with standard vim/neovim customization capabilities and improve the experience for vim power users.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗