Overview
CodeMirror Vim allows you to create custom key mappings using the Vim API. You can map keys in different modes (normal, insert, visual) to customize your editing experience.Basic Key Mapping
UseVim.map() to create custom key mappings:
Mapping Keys in Different Modes
The third parameter specifies the context (mode) where the mapping applies.Insert Mode Mappings
Map keys that work only in insert mode:This is a popular mapping that allows you to quickly exit insert mode without reaching for the Escape key.
Context Parameter
The context parameter can be one of the following:"insert"- Mapping applies only in insert mode"normal"- Mapping applies only in normal mode"visual"- Mapping applies only in visual mode- Omitted - Mapping applies in normal mode by default
Context-specific mappings allow you to use the same key combination for different actions depending on the current mode.
Common Mapping Examples
Unmapping Keys
Remove a previously defined mapping withVim.unmap():
Special Key Notation
CodeMirror Vim supports Vim’s special key notation:<Esc>- Escape key<CR>- Enter/Return<Space>- Space bar<BS>- Backspace<C-x>- Control + x<A-x>- Alt + x<S-x>- Shift + x<Leader>- Leader key (if configured)
API Reference
Vim.map()
Map a key sequence to another key sequence or command.lhs- Left-hand side: the key(s) to maprhs- Right-hand side: the key(s) or command to executecontext- Optional mode context:"insert","normal", or"visual"
Vim.unmap()
Remove a key mapping.lhs- The key(s) to unmapcontext- The mode context where the mapping should be removed

