on aef00a3 help sign in
helix/book/src/keymap.md
404 lines 32 kB history raw
1# Keymap
3- [Normal mode](#normal-mode)
4 - [Movement](#movement)
5 - [Changes](#changes)
6 - [Shell](#shell)
7 - [Selection manipulation](#selection-manipulation)
8 - [Search](#search)
9 - [Minor modes](#minor-modes)
10 - [View mode](#view-mode)
11 - [Goto mode](#goto-mode)
12 - [Match mode](#match-mode)
13 - [Window mode](#window-mode)
14 - [Space mode](#space-mode)
15 - [Popup](#popup)
16 - [Unimpaired](#unimpaired)
17- [Insert Mode](#insert-mode)
18- [Select / extend mode](#select--extend-mode)
19- [Picker](#picker)
20- [Prompt](#prompt)
22> 💡 Mappings marked (**LSP**) require an active language server for the file.
24> 💡 Mappings marked (**TS**) require a tree-sitter grammar for the filetype.
26## Normal mode
28### Movement
30> NOTE: Unlike vim, `f`, `F`, `t` and `T` are not confined to the current line.
32| Key | Description | Command |
33| ----- | ----------- | ------- |
34| `h`, `Left` | Move left | `move_char_left` |
35| `j`, `Down` | Move down | `move_line_down` |
36| `k`, `Up` | Move up | `move_line_up` |
37| `l`, `Right` | Move right | `move_char_right` |
38| `w` | Move next word start | `move_next_word_start` |
39| `b` | Move previous word start | `move_prev_word_start` |
40| `e` | Move next word end | `move_next_word_end` |
41| `W` | Move next WORD start | `move_next_long_word_start` |
42| `B` | Move previous WORD start | `move_prev_long_word_start` |
43| `E` | Move next WORD end | `move_next_long_word_end` |
44| `t` | Find 'till next char | `find_till_char` |
45| `f` | Find next char | `find_next_char` |
46| `T` | Find 'till previous char | `till_prev_char` |
47| `F` | Find previous char | `find_prev_char` |
48| `G` | Go to line number `<n>` | `goto_line` |
49| `Alt-.` | Repeat last motion (`f`, `t` or `m`) | `repeat_last_motion` |
50| `Home` | Move to the start of the line | `goto_line_start` |
51| `End` | Move to the end of the line | `goto_line_end` |
52| `Ctrl-b`, `PageUp` | Move page up | `page_up` |
53| `Ctrl-f`, `PageDown` | Move page down | `page_down` |
54| `Ctrl-u` | Move half page up | `half_page_up` |
55| `Ctrl-d` | Move half page down | `half_page_down` |
56| `Ctrl-i` | Jump forward on the jumplist | `jump_forward` |
57| `Ctrl-o` | Jump backward on the jumplist | `jump_backward` |
58| `Ctrl-s` | Save the current selection to the jumplist | `save_selection` |
60### Changes
62| Key | Description | Command |
63| ----- | ----------- | ------- |
64| `r` | Replace with a character | `replace` |
65| `R` | Replace with yanked text | `replace_with_yanked` |
66| `~` | Switch case of the selected text | `switch_case` |
67| `` ` `` | Set the selected text to lower case | `switch_to_lowercase` |
68| `` Alt-` `` | Set the selected text to upper case | `switch_to_uppercase` |
69| `i` | Insert before selection | `insert_mode` |
70| `a` | Insert after selection (append) | `append_mode` |
71| `I` | Insert at the start of the line | `prepend_to_line` |
72| `A` | Insert at the end of the line | `append_to_line` |
73| `o` | Open new line below selection | `open_below` |
74| `O` | Open new line above selection | `open_above` |
75| `.` | Repeat last insert | N/A |
76| `u` | Undo change | `undo` |
77| `U` | Redo change | `redo` |
78| `Alt-u` | Move backward in history | `earlier` |
79| `Alt-U` | Move forward in history | `later` |
80| `y` | Yank selection | `yank` |
81| `p` | Paste after selection | `paste_after` |
82| `P` | Paste before selection | `paste_before` |
83| `"` `<reg>` | Select a register to yank to or paste from | `select_register` |
84| `>` | Indent selection | `indent` |
85| `<` | Unindent selection | `unindent` |
86| `=` | Format selection (currently nonfunctional/disabled) (**LSP**) | `format_selections` |
87| `d` | Delete selection | `delete_selection` |
88| `Alt-d` | Delete selection, without yanking | `delete_selection_noyank` |
89| `c` | Change selection (delete and enter insert mode) | `change_selection` |
90| `Alt-c` | Change selection (delete and enter insert mode, without yanking) | `change_selection_noyank` |
91| `Ctrl-a` | Increment object (number) under cursor | `increment` |
92| `Ctrl-x` | Decrement object (number) under cursor | `decrement` |
93| `Q` | Start/stop macro recording to the selected register (experimental) | `record_macro` |
94| `q` | Play back a recorded macro from the selected register (experimental) | `replay_macro` |
96#### Shell
98| Key | Description | Command |
99| ------ | ----------- | ------- |
100| <code>&#124;</code> | Pipe each selection through shell command, replacing with output | `shell_pipe` |
101| <code>Alt-&#124;</code> | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
102| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
103| `Alt-!` | Run shell command, appending output after each selection | `shell_append_output` |
104| `$` | Pipe each selection into shell command, keep selections where command returned 0 | `shell_keep_pipe` |
107### Selection manipulation
109| Key | Description | Command |
110| ----- | ----------- | ------- |
111| `s` | Select all regex matches inside selections | `select_regex` |
112| `S` | Split selection into subselections on regex matches | `split_selection` |
113| `Alt-s` | Split selection on newlines | `split_selection_on_newline` |
114| `&` | Align selection in columns | `align_selections` |
115| `_` | Trim whitespace from the selection | `trim_selections` |
116| `;` | Collapse selection onto a single cursor | `collapse_selection` |
117| `Alt-;` | Flip selection cursor and anchor | `flip_selections` |
118| `Alt-:` | Ensures the selection is in forward direction | `ensure_selections_forward` |
119| `,` | Keep only the primary selection | `keep_primary_selection` |
120| `Alt-,` | Remove the primary selection | `remove_primary_selection` |
121| `C` | Copy selection onto the next line (Add cursor below) | `copy_selection_on_next_line` |
122| `Alt-C` | Copy selection onto the previous line (Add cursor above) | `copy_selection_on_prev_line` |
123| `(` | Rotate main selection backward | `rotate_selections_backward` |
124| `)` | Rotate main selection forward | `rotate_selections_forward` |
125| `Alt-(` | Rotate selection contents backward | `rotate_selection_contents_backward` |
126| `Alt-)` | Rotate selection contents forward | `rotate_selection_contents_forward` |
127| `%` | Select entire file | `select_all` |
128| `x` | Select current line, if already selected, extend to next line | `extend_line` |
129| `X` | Extend selection to line bounds (line-wise selection) | `extend_to_line_bounds` |
130| `Alt-x` | Shrink selection to line bounds (line-wise selection) | `shrink_to_line_bounds` |
131| `J` | Join lines inside selection | `join_selections` |
132| `K` | Keep selections matching the regex | `keep_selections` |
133| `Alt-K` | Remove selections matching the regex | `remove_selections` |
134| `Ctrl-c` | Comment/uncomment the selections | `toggle_comments` |
135| `Alt-o`, `Alt-up` | Expand selection to parent syntax node (**TS**) | `expand_selection` |
136| `Alt-i`, `Alt-down` | Shrink syntax tree object selection (**TS**) | `shrink_selection` |
137| `Alt-p`, `Alt-left` | Select previous sibling node in syntax tree (**TS**) | `select_prev_sibling` |
138| `Alt-n`, `Alt-right` | Select next sibling node in syntax tree (**TS**) | `select_next_sibling` |
140### Search
142Search commands all operate on the `/` register by default. Use `"<char>` to operate on a different one.
144| Key | Description | Command |
145| ----- | ----------- | ------- |
146| `/` | Search for regex pattern | `search` |
147| `?` | Search for previous pattern | `rsearch` |
148| `n` | Select next search match | `search_next` |
149| `N` | Select previous search match | `search_prev` |
150| `*` | Use current selection as the search pattern | `search_selection` |
152### Minor modes
154These sub-modes are accessible from normal mode and typically switch back to normal mode after a command.
156| Key | Description | Command |
157| ----- | ----------- | ------- |
158| `v` | Enter [select (extend) mode](#select--extend-mode) | `select_mode` |
159| `g` | Enter [goto mode](#goto-mode) | N/A |
160| `m` | Enter [match mode](#match-mode) | N/A |
161| `:` | Enter command mode | `command_mode` |
162| `z` | Enter [view mode](#view-mode) | N/A |
163| `Z` | Enter sticky [view mode](#view-mode) | N/A |
164| `Ctrl-w` | Enter [window mode](#window-mode) | N/A |
165| `Space` | Enter [space mode](#space-mode) | N/A |
167#### View mode
169View mode is intended for scrolling and manipulating the view without changing
170the selection. The "sticky" variant of this mode is persistent; use the Escape
171key to return to normal mode after usage (useful when you're simply looking
172over text and not actively editing it).
175| Key | Description | Command |
176| ----- | ----------- | ------- |
177| `z`, `c` | Vertically center the line | `align_view_center` |
178| `t` | Align the line to the top of the screen | `align_view_top` |
179| `b` | Align the line to the bottom of the screen | `align_view_bottom` |
180| `m` | Align the line to the middle of the screen (horizontally) | `align_view_middle` |
181| `j`, `down` | Scroll the view downwards | `scroll_down` |
182| `k`, `up` | Scroll the view upwards | `scroll_up` |
183| `Ctrl-f`, `PageDown` | Move page down | `page_down` |
184| `Ctrl-b`, `PageUp` | Move page up | `page_up` |
185| `Ctrl-d` | Move half page down | `half_page_down` |
186| `Ctrl-u` | Move half page up | `half_page_up` |
188#### Goto mode
190Jumps to various locations.
192| Key | Description | Command |
193| ----- | ----------- | ------- |
194| `g` | Go to line number `<n>` else start of file | `goto_file_start` |
195| `e` | Go to the end of the file | `goto_last_line` |
196| `f` | Go to files in the selection | `goto_file` |
197| `h` | Go to the start of the line | `goto_line_start` |
198| `l` | Go to the end of the line | `goto_line_end` |
199| `s` | Go to first non-whitespace character of the line | `goto_first_nonwhitespace` |
200| `t` | Go to the top of the screen | `goto_window_top` |
201| `c` | Go to the middle of the screen | `goto_window_center` |
202| `b` | Go to the bottom of the screen | `goto_window_bottom` |
203| `d` | Go to definition (**LSP**) | `goto_definition` |
204| `y` | Go to type definition (**LSP**) | `goto_type_definition` |
205| `r` | Go to references (**LSP**) | `goto_reference` |
206| `i` | Go to implementation (**LSP**) | `goto_implementation` |
207| `a` | Go to the last accessed/alternate file | `goto_last_accessed_file` |
208| `m` | Go to the last modified/alternate file | `goto_last_modified_file` |
209| `n` | Go to next buffer | `goto_next_buffer` |
210| `p` | Go to previous buffer | `goto_previous_buffer` |
211| `.` | Go to last modification in current file | `goto_last_modification` |
213#### Match mode
215Enter this mode using `m` from normal mode. See the relevant section
216in [Usage](./usage.md) for an explanation about [surround](./usage.md#surround)
217and [textobject](./usage.md#textobject) usage.
219| Key | Description | Command |
220| ----- | ----------- | ------- |
221| `m` | Goto matching bracket (**TS**) | `match_brackets` |
222| `s` `<char>` | Surround current selection with `<char>` | `surround_add` |
223| `r` `<from><to>` | Replace surround character `<from>` with `<to>` | `surround_replace` |
224| `d` `<char>` | Delete surround character `<char>` | `surround_delete` |
225| `a` `<object>` | Select around textobject | `select_textobject_around` |
226| `i` `<object>` | Select inside textobject | `select_textobject_inner` |
228TODO: Mappings for selecting syntax nodes (a superset of `[`).
230#### Window mode
232This layer is similar to vim keybindings as kakoune does not support window.
234| Key | Description | Command |
235| ----- | ------------- | ------- |
236| `w`, `Ctrl-w` | Switch to next window | `rotate_view` |
237| `v`, `Ctrl-v` | Vertical right split | `vsplit` |
238| `s`, `Ctrl-s` | Horizontal bottom split | `hsplit` |
239| `f` | Go to files in the selection in horizontal splits | `goto_file` |
240| `F` | Go to files in the selection in vertical splits | `goto_file` |
241| `h`, `Ctrl-h`, `Left` | Move to left split | `jump_view_left` |
242| `j`, `Ctrl-j`, `Down` | Move to split below | `jump_view_down` |
243| `k`, `Ctrl-k`, `Up` | Move to split above | `jump_view_up` |
244| `l`, `Ctrl-l`, `Right` | Move to right split | `jump_view_right` |
245| `q`, `Ctrl-q` | Close current window | `wclose` |
246| `o`, `Ctrl-o` | Only keep the current window, closing all the others | `wonly` |
247| `H` | Swap window to the left | `swap_view_left` |
248| `J` | Swap window downwards | `swap_view_down` |
249| `K` | Swap window upwards | `swap_view_up` |
250| `L` | Swap window to the right | `swap_view_right` |
252#### Space mode
254This layer is a kludge of mappings, mostly pickers.
257| Key | Description | Command |
258| ----- | ----------- | ------- |
259| `f` | Open file picker | `file_picker` |
260| `b` | Open buffer picker | `buffer_picker` |
261| `j` | Open jumplist picker | `jumplist_picker` |
262| `k` | Show documentation for item under cursor in a [popup](#popup) (**LSP**) | `hover` |
263| `s` | Open document symbol picker (**LSP**) | `symbol_picker` |
264| `S` | Open workspace symbol picker (**LSP**) | `workspace_symbol_picker` |
265| `g` | Open document diagnostics picker (**LSP**) | `diagnostics_picker` |
266| `G` | Open workspace diagnostics picker (**LSP**) | `workspace_diagnostics_picker`
267| `r` | Rename symbol (**LSP**) | `rename_symbol` |
268| `a` | Apply code action (**LSP**) | `code_action` |
269| `'` | Open last fuzzy picker | `last_picker` |
270| `w` | Enter [window mode](#window-mode) | N/A |
271| `p` | Paste system clipboard after selections | `paste_clipboard_after` |
272| `P` | Paste system clipboard before selections | `paste_clipboard_before` |
273| `y` | Join and yank selections to clipboard | `yank_joined_to_clipboard` |
274| `Y` | Yank main selection to clipboard | `yank_main_selection_to_clipboard` |
275| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
276| `/` | Global search in workspace folder | `global_search` |
277| `?` | Open command palette | `command_palette` |
279> TIP: Global search displays results in a fuzzy picker, use `space + '` to bring it back up after opening a file.
281##### Popup
283Displays documentation for item under cursor.
285| Key | Description |
286| ---- | ----------- |
287| `Ctrl-u` | Scroll up |
288| `Ctrl-d` | Scroll down |
290#### Unimpaired
292Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaired).
294| Key | Description | Command |
295| ----- | ----------- | ------- |
296| `[d` | Go to previous diagnostic (**LSP**) | `goto_prev_diag` |
297| `]d` | Go to next diagnostic (**LSP**) | `goto_next_diag` |
298| `[D` | Go to first diagnostic in document (**LSP**) | `goto_first_diag` |
299| `]D` | Go to last diagnostic in document (**LSP**) | `goto_last_diag` |
300| `]f` | Go to next function (**TS**) | `goto_next_function` |
301| `[f` | Go to previous function (**TS**) | `goto_prev_function` |
302| `]c` | Go to next class (**TS**) | `goto_next_class` |
303| `[c` | Go to previous class (**TS**) | `goto_prev_class` |
304| `]a` | Go to next argument/parameter (**TS**) | `goto_next_parameter` |
305| `[a` | Go to previous argument/parameter (**TS**) | `goto_prev_parameter` |
306| `]o` | Go to next comment (**TS**) | `goto_next_comment` |
307| `[o` | Go to previous comment (**TS**) | `goto_prev_comment` |
308| `]t` | Go to next test (**TS**) | `goto_next_test` |
309| `]t` | Go to previous test (**TS**) | `goto_prev_test` |
310| `]p` | Go to next paragraph | `goto_next_paragraph` |
311| `[p` | Go to previous paragraph | `goto_prev_paragraph` |
312| `[space` | Add newline above | `add_newline_above` |
313| `]space` | Add newline below | `add_newline_below` |
315## Insert Mode
317We support many readline/emacs style bindings in insert mode for
318convenience. These can be helpful for making simple modifications
319without escaping to normal mode, but beware that you will not have an
320undo-able "save point" until you return to normal mode.
322| Key | Description | Command |
323| ----- | ----------- | ------- |
324| `Escape` | Switch to normal mode | `normal_mode` |
325| `Ctrl-x` | Autocomplete | `completion` |
326| `Ctrl-r` | Insert a register content | `insert_register` |
327| `Ctrl-w`, `Alt-Backspace`, `Ctrl-Backspace` | Delete previous word | `delete_word_backward` |
328| `Alt-d`, `Alt-Delete`, `Ctrl-Delete` | Delete next word | `delete_word_forward` |
329| `Alt-b`, `Ctrl-Left` | Backward a word | `move_prev_word_end` |
330| `Ctrl-b`, `Left` | Backward a char | `move_char_left` |
331| `Alt-f`, `Ctrl-Right` | Forward a word | `move_next_word_start` |
332| `Ctrl-f`, `Right` | Forward a char | `move_char_right` |
333| `Ctrl-e`, `End` | Move to line end | `goto_line_end_newline` |
334| `Ctrl-a`, `Home` | Move to line start | `goto_line_start` |
335| `Ctrl-u` | Delete to start of line | `kill_to_line_start` |
336| `Ctrl-k` | Delete to end of line | `kill_to_line_end` |
337| `Ctrl-j`, `Enter` | Insert new line | `insert_newline` |
338| `Backspace`, `Ctrl-h` | Delete previous char | `delete_char_backward` |
339| `Delete`, `Ctrl-d` | Delete next char | `delete_char_forward` |
340| `Ctrl-p`, `Up` | Move to previous line | `move_line_up` |
341| `Ctrl-n`, `Down` | Move to next line | `move_line_down` |
342| `PageUp` | Move one page up | `page_up` |
343| `PageDown` | Move one page down | `page_down` |
344| `Alt->` | Go to end of buffer | `goto_file_end` |
345| `Alt-<` | Go to start of buffer | `goto_file_start` |
347## Select / extend mode
349This mode echoes Normal mode, but changes any movements to extend
350selections rather than replace them. Goto motions are also changed to
351extend, so that `vgl` for example extends the selection to the end of
352the line.
354Search is also affected. By default, `n` and `N` will remove the current
355selection and select the next instance of the search term. Toggling this
356mode before pressing `n` or `N` makes it possible to keep the current
357selection. Toggling it on and off during your iterative searching allows
358you to selectively add search terms to your selections.
360## Picker
362Keys to use within picker. Remapping currently not supported.
364| Key | Description |
365| ----- | ------------- |
366| `Tab`, `Up`, `Ctrl-p` | Previous entry |
367| `PageUp`, `Ctrl-u` | Page up |
368| `Shift-tab`, `Down`, `Ctrl-n`| Next entry |
369| `PageDown`, `Ctrl-d` | Page down |
370| `Home` | Go to first entry |
371| `End` | Go to last entry |
372| `Ctrl-space` | Filter options |
373| `Enter` | Open selected |
374| `Ctrl-s` | Open horizontally |
375| `Ctrl-v` | Open vertically |
376| `Ctrl-t` | Toggle preview |
377| `Escape`, `Ctrl-c` | Close picker |
379## Prompt
381Keys to use within prompt, Remapping currently not supported.
383| Key | Description |
384| ----- | ------------- |
385| `Escape`, `Ctrl-c` | Close prompt |
386| `Alt-b`, `Ctrl-Left` | Backward a word |
387| `Ctrl-b`, `Left` | Backward a char |
388| `Alt-f`, `Ctrl-Right` | Forward a word |
389| `Ctrl-f`, `Right` | Forward a char |
390| `Ctrl-e`, `End` | Move prompt end |
391| `Ctrl-a`, `Home` | Move prompt start |
392| `Ctrl-w`, `Alt-Backspace`, `Ctrl-Backspace` | Delete previous word |
393| `Alt-d`, `Alt-Delete`, `Ctrl-Delete` | Delete next word |
394| `Ctrl-u` | Delete to start of line |
395| `Ctrl-k` | Delete to end of line |
396| `backspace`, `Ctrl-h` | Delete previous char |
397| `delete`, `Ctrl-d` | Delete next char |
398| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later |
399| `Ctrl-p`, `Up` | Select previous history |
400| `Ctrl-n`, `Down` | Select next history |
401| `Ctrl-r` | Insert the content of the register selected by following input char |
402| `Tab` | Select next completion item |
403| `BackTab` | Select previous completion item |
404| `Enter` | Open selected |