Keys
For a mostly-complete list of the default key mappings, see default keymappings, or execute :map or :whichkey.
You can define key mappings in Glide using the same syntax as in vim, e.g. <leader>t, the config looks like this:
glide.keymaps.set("normal", "<leader>r", "config_reload");
Here, each argument corresponds to:
- The mode the keymap should apply in.
- The key sequence to activate it.
- The excmd to run when activated. (note this can also just be a function)
You can also specify multiple modes at once using an array:
glide.keymaps.set(["normal", "visual"], "<leader>r", "...");
Instead of an excmd, you can pass a function directly:
glide.keymaps.set("normal", "<leader>r", () => {
glide.hints.show();
});
You can also delete existing keymaps:
glide.keymaps.del("normal", "f");
Key codes
By default, Glide matches keymaps from the KeyboardEvent.key property*, which corresponds to the key that would be inserted into a text editor if you typed it directly. However this can be undesirable if you have multiple keyboard layouts, or a non-english keyboard layout as you would have to add a separate key mapping for each keyboard layout you use.
In that case, you can configure Glide to use the KeyboardEvent.code property instead, which corresponds to the physical key that you pressed, regardless of any software layout.
glide.o.keyboard_layout = "qwerty";
glide.o.keymaps_use_physical_layout = "force";
Note that Glide needs a way to map the key code to the corresponding key string in mappings. For example, what should pressing Shift + Digit2 be matched against? The answer can change depending on your specific keyboard. On a US keyboard with a qwerty layout you would expect it to match against keymaps using @, but on a German keyboard it should be ".
The default keyboard layout is US qwerty. If you use a different layout, see the glide.o.keyboard_layouts option.
By default, on macOS, Glide resolves keymaps from the code property when the Option key is pressed to avoid surprising behaviour with diacritics.
If this is undesirable, set the glide.o.keymaps_use_physical_layout property to "never".
Syntax
- Key combinations are case-sensitive, <C-a> and <C-A> are treated differently.
- Modifiers are case-sensitive, <C-a> is allowed but <c-a> is not (yet).
- Modifiers are not order-sensitive and can be specified in any order. <D-S-a> and <S-D-a> are equivalent.
- Regular characters (a-z, 0-9) don't need to be wrapped in angle brackets unless they're combined with modifiers, e.g. <C-a>.
- Special keys must always be wrapped in angle backets, and can be combined with modifiers, e.g. <leader> and <D-leader>.
Modifier keys
Modifiers are added as prefixes inside angle brackets and combined with a key using a -.
- <C-> - Control key
- <S-> - Shift key
- <A-> or <M-> - Alt/Meta key
- <D-> - Command key (macOS)
e.g.
- <C-a> - Control + a
- <S-Tab> - Shift + Tab
- <C-S-v> - Control + Shift + v
- <D-s> - Command + s (macOS)
Special keys
Special keys are wrapped in angle brackets <>. For example:
- <CR> or <Enter> - Enter/Return key
- <BS> or <Backspace> - Backspace key
- <Space> - Space bar
- <Esc> or <Escape> - Escape key
- <Tab> - Tab key
- <Del> or <Delete> - Delete key
- <Up>, <Down>, <Left>, <Right> - Arrow keys
- <Home> - Home key
- <End> - End key
- <PageUp> - Page Up key
- <PageDown> - Page Down key
- <F1> through <F12> - Function keys
Alias keys
Some keys have aliases to help disambiguate syntax:
- <Bar> - Vertical bar |
- <Bslash> - Backslash \
- <lt> - Less than <
For example, <lt> is needed in some cases so that < can be used alongside modifier keys.
- < -> valid, < by itself
- <D-> -> invalid
- <D-lt> -> valid, Command + <