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