Overview
TheVim.map() function creates custom key mappings in CodeMirror Vim mode. You can map key sequences to other key sequences, allowing you to customize your Vim keybindings.
Signature
Parameters
The left-hand side: the key sequence to map from. This is the key combination you’ll press.
The right-hand side: the key sequence to map to. This is what will be executed when you press the
lhs keys.The mode context where this mapping applies. Valid values:
"insert"- Mapping only works in insert mode"normal"- Mapping only works in normal mode (default)"visual"- Mapping only works in visual mode
Return Value
This function does not return a value.
Examples
Map in Insert Mode
Mapjj to <Esc> to exit insert mode:
Map in Normal Mode
MapY to y$ to yank to end of line:
Complex Mapping
Map a key sequence to multiple commands:Notes
- Key mappings are global and persist across all editor instances
- Special keys should be wrapped in angle brackets (e.g.,
<Esc>,<CR>,<Space>) - Mappings defined with
map()are recursive, meaning therhscan trigger other mappings - Use
Vim.noremap()if you want non-recursive mappings - To remove a mapping, use
Vim.unmap()
See Also
- Vim.unmap() - Remove key mappings
- Vim.noremap() - Create non-recursive mappings

