on 0eadeab help sign in
helix/book/src/keymap.md
324 lines 24 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| `Alt-.` | Repeat last motion (`f`, `t` or `m`) | `repeat_last_motion` |
29| `Home` | Move to the start of the line | `goto_line_start` |
30| `End` | Move to the end of the line | `goto_line_end` |
31| `PageUp` | Move page up | `page_up` |
32| `PageDown` | Move page down | `page_down` |
33| `Ctrl-u` | Move half page up | `half_page_up` |
34| `Ctrl-d` | Move half page down | `half_page_down` |
35| `Ctrl-i` | Jump forward on the jumplist | `jump_forward` |
36| `Ctrl-o` | Jump backward on the jumplist | `jump_backward` |
37| `v` | Enter [select (extend) mode](#select--extend-mode) | `select_mode` |
38| `g` | Enter [goto mode](#goto-mode) | N/A |
39| `m` | Enter [match mode](#match-mode) | N/A |
40| `:` | Enter command mode | `command_mode` |
41| `z` | Enter [view mode](#view-mode) | N/A |
42| `Z` | Enter sticky [view mode](#view-mode) | N/A |
43| `Ctrl-w` | Enter [window mode](#window-mode) | N/A |
44| `Space` | Enter [space mode](#space-mode) | N/A |
46### Changes
48| Key | Description | Command |
49| ----- | ----------- | ------- |
50| `r` | Replace with a character | `replace` |
51| `R` | Replace with yanked text | `replace_with_yanked` |
52| `~` | Switch case of the selected text | `switch_case` |
53| `` ` `` | Set the selected text to lower case | `switch_to_lowercase` |
54| `` Alt-` `` | Set the selected text to upper case | `switch_to_uppercase` |
55| `i` | Insert before selection | `insert_mode` |
56| `a` | Insert after selection (append) | `append_mode` |
57| `I` | Insert at the start of the line | `prepend_to_line` |
58| `A` | Insert at the end of the line | `append_to_line` |
59| `o` | Open new line below selection | `open_below` |
60| `O` | Open new line above selection | `open_above` |
61| `.` | Repeat last change | N/A |
62| `u` | Undo change | `undo` |
63| `U` | Redo change | `redo` |
64| `Alt-u` | Move backward in history | `earlier` |
65| `Alt-U` | Move forward in history | `later` |
66| `y` | Yank selection | `yank` |
67| `p` | Paste after selection | `paste_after` |
68| `P` | Paste before selection | `paste_before` |
69| `"` `<reg>` | Select a register to yank to or paste from | `select_register` |
70| `>` | Indent selection | `indent` |
71| `<` | Unindent selection | `unindent` |
72| `=` | Format selection (**LSP**) | `format_selections` |
73| `d` | Delete selection | `delete_selection` |
74| `c` | Change selection (delete and enter insert mode) | `change_selection` |
75| `Ctrl-a` | Increment object (number) under cursor | `increment` |
76| `Ctrl-x` | Decrement object (number) under cursor | `decrement` |
78#### Shell
80| Key | Description | Command |
81| ------ | ----------- | ------- |
82| <code>&#124;</code> | Pipe each selection through shell command, replacing with output | `shell_pipe` |
83| <code>A-&#124;</code> | Pipe each selection into shell command, ignoring output | `shell_pipe_to` |
84| `!` | Run shell command, inserting output before each selection | `shell_insert_output` |
85| `A-!` | Run shell command, appending output after each selection | `shell_append_output` |
88### Selection manipulation
90| Key | Description | Command |
91| ----- | ----------- | ------- |
92| `s` | Select all regex matches inside selections | `select_regex` |
93| `S` | Split selection into subselections on regex matches | `split_selection` |
94| `Alt-s` | Split selection on newlines | `split_selection_on_newline` |
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| `,` | Keep only the primary selection | `keep_primary_selection` |
99| `Alt-,` | Remove the primary selection | `remove_primary_selection` |
100| `C` | Copy selection onto the next line (Add cursor below) | `copy_selection_on_next_line` |
101| `Alt-C` | Copy selection onto the previous line (Add cursor above) | `copy_selection_on_prev_line` |
102| `(` | Rotate main selection backward | `rotate_selections_backward` |
103| `)` | Rotate main selection forward | `rotate_selections_forward` |
104| `Alt-(` | Rotate selection contents backward | `rotate_selection_contents_backward` |
105| `Alt-)` | Rotate selection contents forward | `rotate_selection_contents_forward` |
106| `%` | Select entire file | `select_all` |
107| `x` | Select current line, if already selected, extend to next line | `extend_line` |
108| `X` | Extend selection to line bounds (line-wise selection) | `extend_to_line_bounds` |
109| | Expand selection to parent syntax node TODO: pick a key (**TS**) | `expand_selection` |
110| `J` | Join lines inside selection | `join_selections` |
111| `K` | Keep selections matching the regex | `keep_selections` |
112| `Alt-K` | Remove selections matching the regex | `remove_selections` |
113| `$` | Pipe each selection into shell command, keep selections where command returned 0 | `shell_keep_pipe` |
114| `Ctrl-c` | Comment/uncomment the selections | `toggle_comments` |
116### Search
119| Key | Description | Command |
120| ----- | ----------- | ------- |
121| `/` | Search for regex pattern | `search` |
122| `?` | Search for previous pattern | `rsearch` |
123| `n` | Select next search match | `search_next` |
124| `N` | Select previous search match | `search_prev` |
125| `*` | Use current selection as the search pattern | `search_selection` |
127### Minor modes
129These sub-modes are accessible from normal mode and typically switch back to normal mode after a command.
131#### View mode
133View mode is intended for scrolling and manipulating the view without changing
134the selection. The "sticky" variant of this mode is persistent; use the Escape
135key to return to normal mode after usage (useful when you're simply looking
136over text and not actively editing it).
139| Key | Description | Command |
140| ----- | ----------- | ------- |
141| `z` , `c` | Vertically center the line | `align_view_center` |
142| `t` | Align the line to the top of the screen | `align_view_top` |
143| `b` | Align the line to the bottom of the screen | `align_view_bottom` |
144| `m` | Align the line to the middle of the screen (horizontally) | `align_view_middle` |
145| `j` , `down` | Scroll the view downwards | `scroll_down` |
146| `k` , `up` | Scroll the view upwards | `scroll_up` |
147| `f` | Move page down | `page_down` |
148| `b` | Move page up | `page_up` |
149| `d` | Move half page down | `half_page_down` |
150| `u` | Move half page up | `half_page_up` |
152#### Goto mode
154Jumps to various locations.
156| Key | Description | Command |
157| ----- | ----------- | ------- |
158| `g` | Go to the start of the file | `goto_file_start` |
159| `e` | Go to the end of the file | `goto_last_line` |
160| `h` | Go to the start of the line | `goto_line_start` |
161| `l` | Go to the end of the line | `goto_line_end` |
162| `s` | Go to first non-whitespace character of the line | `goto_first_nonwhitespace` |
163| `t` | Go to the top of the screen | `goto_window_top` |
164| `m` | Go to the middle of the screen | `goto_window_middle` |
165| `b` | Go to the bottom of the screen | `goto_window_bottom` |
166| `d` | Go to definition (**LSP**) | `goto_definition` |
167| `y` | Go to type definition (**LSP**) | `goto_type_definition` |
168| `r` | Go to references (**LSP**) | `goto_reference` |
169| `i` | Go to implementation (**LSP**) | `goto_implementation` |
170| `a` | Go to the last accessed/alternate file | `goto_last_accessed_file` |
171| `n` | Go to next buffer | `goto_next_buffer` |
172| `p` | Go to previous buffer | `goto_previous_buffer` |
173| `.` | Go to last modification in current file | `goto_last_modification` |
175#### Match mode
177Enter this mode using `m` from normal mode. See the relavant section
178in [Usage](./usage.md) for an explanation about [surround](./usage.md#surround)
179and [textobject](./usage.md#textobject) usage.
181| Key | Description | Command |
182| ----- | ----------- | ------- |
183| `m` | Goto matching bracket (**TS**) | `match_brackets` |
184| `s` `<char>` | Surround current selection with `<char>` | `surround_add` |
185| `r` `<from><to>` | Replace surround character `<from>` with `<to>` | `surround_replace` |
186| `d` `<char>` | Delete surround character `<char>` | `surround_delete` |
187| `a` `<object>` | Select around textobject | `select_textobject_around` |
188| `i` `<object>` | Select inside textobject | `select_textobject_inner` |
190TODO: Mappings for selecting syntax nodes (a superset of `[`).
192#### Window mode
194This layer is similar to vim keybindings as kakoune does not support window.
196| Key | Description | Command |
197| ----- | ------------- | ------- |
198| `w`, `Ctrl-w` | Switch to next window | `rotate_view` |
199| `v`, `Ctrl-v` | Vertical right split | `vsplit` |
200| `s`, `Ctrl-s` | Horizontal bottom split | `hsplit` |
201| `h`, `Ctrl-h`, `left` | Move to left split | `jump_view_left` |
202| `j`, `Ctrl-j`, `down` | Move to split below | `jump_view_down` |
203| `k`, `Ctrl-k`, `up` | Move to split above | `jump_view_up` |
204| `l`, `Ctrl-l`, `right` | Move to right split | `jump_view_right` |
205| `q`, `Ctrl-q` | Close current window | `wclose` |
206| `o`, `Ctrl-o` | Only keep the current window, closing all the others | `wonly` |
208#### Space mode
210This layer is a kludge of mappings, mostly pickers.
213| Key | Description | Command |
214| ----- | ----------- | ------- |
215| `f` | Open file picker | `file_picker` |
216| `b` | Open buffer picker | `buffer_picker` |
217| `k` | Show documentation for item under cursor in a [popup](#popup) (**LSP**) | `hover` |
218| `s` | Open document symbol picker (**LSP**) | `symbol_picker` |
219| `S` | Open workspace symbol picker (**LSP**) | `workspace_symbol_picker` |
220| `r` | Rename symbol (**LSP**) | `rename_symbol` |
221| `a` | Apply code action (**LSP**) | `code_action` |
222| `'` | Open last fuzzy picker | `last_picker` |
223| `w` | Enter [window mode](#window-mode) | N/A |
224| `p` | Paste system clipboard after selections | `paste_clipboard_after` |
225| `P` | Paste system clipboard before selections | `paste_clipboard_before` |
226| `y` | Join and yank selections to clipboard | `yank_joined_to_clipboard` |
227| `Y` | Yank main selection to clipboard | `yank_main_selection_to_clipboard` |
228| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
229| `/` | Global search in workspace folder | `global_search` |
231> TIP: Global search displays results in a fuzzy picker, use `space + '` to bring it back up after opening a file.
233##### Popup
235Displays documentation for item under cursor.
237| Key | Description |
238| ---- | ----------- |
239| `Ctrl-u` | Scroll up |
240| `Ctrl-d` | Scroll down |
242#### Unimpaired
244Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaired).
246| Key | Description | Command |
247| ----- | ----------- | ------- |
248| `[d` | Go to previous diagnostic (**LSP**) | `goto_prev_diag` |
249| `]d` | Go to next diagnostic (**LSP**) | `goto_next_diag` |
250| `[D` | Go to first diagnostic in document (**LSP**) | `goto_first_diag` |
251| `]D` | Go to last diagnostic in document (**LSP**) | `goto_last_diag` |
252| `[space` | Add newline above | `add_newline_above` |
253| `]space` | Add newline below | `add_newline_below` |
255## Insert Mode
257| Key | Description | Command |
258| ----- | ----------- | ------- |
259| `Escape` | Switch to normal mode | `normal_mode` |
260| `Ctrl-x` | Autocomplete | `completion` |
261| `Ctrl-r` | Insert a register content | `insert_register` |
262| `Ctrl-w` | Delete previous word | `delete_word_backward` |
263| `Alt-d` | Delete next word | `delete_word_forward` |
264| `Alt-b`, `Alt-Left` | Backward a word | `move_prev_word_end` |
265| `Ctrl-b`, `Left` | Backward a char | `move_char_left` |
266| `Alt-f`, `Alt-Right` | Forward a word | `move_next_word_start` |
267| `Ctrl-f`, `Right` | Forward a char | `move_char_right` |
268| `Ctrl-e`, `End` | move to line end | `goto_line_end_newline` |
269| `Ctrl-a`, `Home` | move to line start | `goto_line_start` |
270| `Ctrl-u` | delete to start of line | `kill_to_line_start` |
271| `Ctrl-k` | delete to end of line | `kill_to_line_end` |
272| `backspace`, `Ctrl-h` | delete previous char | `delete_char_backward` |
273| `delete`, `Ctrl-d` | delete previous char | `delete_char_forward` |
274| `Ctrl-p`, `Up` | move to previous line | `move_line_up` |
275| `Ctrl-n`, `Down` | move to next line | `move_line_down` |
277## Select / extend mode
279I'm still pondering whether to keep this mode or not. It changes movement
280commands (including goto) to extend the existing selection instead of replacing it.
282> NOTE: It's a bit confusing at the moment because extend hasn't been
283> implemented for all movement commands yet.
285# Picker
287Keys to use within picker. Remapping currently not supported.
289| Key | Description |
290| ----- | ------------- |
291| `Up`, `Ctrl-k`, `Ctrl-p` | Previous entry |
292| `Down`, `Ctrl-j`, `Ctrl-n` | Next entry |
293| `Ctrl-space` | Filter options |
294| `Enter` | Open selected |
295| `Ctrl-s` | Open horizontally |
296| `Ctrl-v` | Open vertically |
297| `Escape`, `Ctrl-c` | Close picker |
299# Prompt
301Keys to use within prompt, Remapping currently not supported.
303| Key | Description |
304| ----- | ------------- |
305| `Escape`, `Ctrl-c` | Close prompt |
306| `Alt-b`, `Alt-Left` | Backward a word |
307| `Ctrl-b`, `Left` | Backward a char |
308| `Alt-f`, `Alt-Right` | Forward a word |
309| `Ctrl-f`, `Right` | Forward a char |
310| `Ctrl-e`, `End` | Move prompt end |
311| `Ctrl-a`, `Home` | Move prompt start |
312| `Ctrl-w` | Delete previous word |
313| `Alt-d` | Delete next word |
314| `Ctrl-u` | Delete to start of line |
315| `Ctrl-k` | Delete to end of line |
316| `backspace`, `Ctrl-h` | Delete previous char |
317| `delete`, `Ctrl-d` | Delete previous char |
318| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later |
319| `Ctrl-p`, `Up` | Select previous history |
320| `Ctrl-n`, `Down` | Select next history |
321| `Tab` | Select next completion item |
322| `BackTab` | Select previous completion item |
323| `Enter` | Open selected |