-
Notifications
You must be signed in to change notification settings - Fork 0
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.
Before remapping, you need to know the command name for the action you want to bind. There are two ways:
-
:Keybindings— opens a reference showing all keybindings with their command names on the right (e.g.gd → :def,F12 → :def,Ctrl+P → :fuzzy) -
Command palette (
F1orCtrl-Shift-P) → search "Open Keybinding Reference"
: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- Run
:Keymaps(orF1→ "Open Keyboard Shortcuts") - A scratch buffer opens — one mapping per line
- Add your mappings in the format
mode keys :command - Save with
:wto validate and persist tosettings.json
Edit ~/.config/vimcode/settings.json:
{
"keymaps": [
"n <C-/> :Comment",
"v <C-/> :Comment",
"n gcc :Comment {count}",
"n <leader>f :Lformat"
]
}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
|
| 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 |
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 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}"
]:unmap n <C-/> " Remove the Ctrl-/ mapping in normal modeOr delete the line from the keymaps editor (:Keymaps) and save.
:map " List all user-defined mappingsIn 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:
- Press F1 → type "keybinding" → select "Open Keybinding Reference" to see all bindings with command names
- Press F1 → type "keyboard" → select "Open Keyboard Shortcuts" to open the keymaps editor
- Add a line like
n <C-H> :hoverorn <F7> :def, then save
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 |
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 |
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.
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 |