Skip to content

Key Remapping

John Donaghy edited this page Mar 11, 2026 · 1 revision

Key Remapping

VimCode supports user-defined key mappings in both Vim and VSCode modes. User keymaps are checked before built-in keys, so they can override defaults.

Discovering command names

Before remapping, you need to know the command name for the action you want to bind. There are two ways:

  1. :Keybindings — opens a reference showing all keybindings with their command names on the right (e.g. gd → :def, F12 → :def, Ctrl+P → :fuzzy)
  2. Command palette (F1 or Ctrl-Shift-P) → search "Open Keybinding Reference"

Adding mappings

From the command line

:map n <C-/> :Comment          " Map Ctrl-/ to toggle comments in normal mode
:map v <C-/> :Comment          " Same for visual mode
:map n <leader>f :Lformat      " Map leader-f to format
:map n gcc :Comment {count}    " Map gcc to comment N lines

From the keymaps editor

  1. Run :Keymaps (or F1 → "Open Keyboard Shortcuts")
  2. A scratch buffer opens — one mapping per line
  3. Add your mappings in the format mode keys :command
  4. Save with :w to validate and persist to settings.json

Directly in settings.json

Edit ~/.config/vimcode/settings.json:

{
    "keymaps": [
        "n <C-/> :Comment",
        "v <C-/> :Comment",
        "n gcc :Comment {count}",
        "n <leader>f :Lformat"
    ]
}

Format

mode keys :command
Part Description Examples
mode n (normal), v (visual), i (insert), c (command) n, v
keys Single char, modifier combo, or multi-key sequence J, <C-/>, <A-c>, gcc, gc
command Ex command prefixed with : :Comment, :Lformat, :def

Key notation

Notation Meaning
<C-x> Ctrl+x
<A-x> Alt+x
<C-S-x> Ctrl+Shift+x
<leader>x Leader key (default: Space) + x
<F5> Function key F5

Special: {count} substitution

Use {count} in the command to substitute the numeric count prefix:

n gcc :Comment {count}

Typing 3gcc runs :Comment 3 (comments 3 lines).

Multi-key sequences

Multi-key sequences like gcc or gc are supported. Intermediate keys are buffered until an exact match is found or a fallthrough occurs.

"keymaps": [
    "n gc :Comment",
    "n gcc :Comment {count}"
]

Removing mappings

:unmap n <C-/>       " Remove the Ctrl-/ mapping in normal mode

Or delete the line from the keymaps editor (:Keymaps) and save.

Listing current mappings

:map                 " List all user-defined mappings

VSCode mode keymaps

In VSCode mode, use mode n for all keymaps (since the editor is always in a single state). Use modifier keys (<C-x>, <A-x>, <F5>) to avoid intercepting normal typing.

Remapping workflow in VSCode mode:

  1. Press F1 → type "keybinding" → select "Open Keybinding Reference" to see all bindings with command names
  2. Press F1 → type "keyboard" → select "Open Keyboard Shortcuts" to open the keymaps editor
  3. Add a line like n <C-H> :hover or n <F7> :def, then save

Configurable panel keys

These keybindings are configured in settings.json under "panel_keys" rather than the keymaps system:

Field Default Action
toggle_sidebar <C-b> Toggle sidebar visibility
focus_explorer <A-e> Focus explorer
focus_search <A-f> Focus search panel
fuzzy_finder <C-p> Open fuzzy file finder
live_grep <C-g> Open live grep modal
open_terminal <C-t> Toggle terminal panel
add_cursor <A-d> Add cursor at next occurrence
select_all_matches <C-S-l> Select all occurrences
split_editor_right <C-\> Split editor right
split_editor_down Split editor down

Configurable explorer keys

Under "explorer_keys" in settings.json:

Field Default Action
new_file a New file prompt
new_folder A New folder prompt
delete D Delete prompt
rename r Rename prompt
move_file M Move file prompt

Configurable completion keys

Under "completion_keys" in settings.json:

Field Default Action
trigger <C-Space> Manually trigger completion popup
accept Tab Accept highlighted completion item

Only specify keys you want to change — unspecified keys keep their defaults.

Available commands for remapping

Run :Keybindings for the full list. Here are some commonly remapped commands:

Command Default key (Vim) Default key (VSCode) Action
:def gd F12 Go to definition
:refs gr Shift+F12 Find references
:hover K Show hover info
:LspImpl <leader>gi Go to implementation
:LspTypedef gy Go to type definition
:Lformat <leader>gf Shift+Alt+F Format document
:Rename <leader>rn F2 Rename symbol
:Comment gcc / gc Ctrl+/ Toggle comment
:fuzzy Ctrl+P Ctrl+P Fuzzy file finder
:sidebar Ctrl+B Ctrl+B Toggle sidebar
:palette Ctrl+Shift+P F1 / Ctrl+Shift+P Command palette
:nextdiag ]d Next diagnostic
:prevdiag [d Previous diagnostic
:nexthunk ]c Next git hunk
:prevhunk [c Previous git hunk

Clone this wiki locally