Translator's note: Excerpted from my translated Helix Book, the full document can be found here .
Mappings marked as LSP require a language server for that file type.
Mappings marked as TS require tree-sitter syntax support for that file type.
Normal mode#
Cursor Movement#
Note: Unlike Vim,
f
,F
,t
, andT
are not limited to the current line.
Key | Description | Command |
---|---|---|
h , Left | Move left | move_char_left |
j , Down | Move down | move_line_down |
k , Up | Move up | move_line_up |
l , Right | Move right | move_char_right |
w | Move to the start of the next word | move_next_word_start |
b | Move to the start of the previous word | move_prev_word_start |
e | Move to the end of the next word | move_next_word_end |
W | Move to the start of the next WORD | move_next_long_word_start |
B | Move to the end of the previous WORD | move_prev_long_word_start |
E | Move to the end of the next WORD | move_next_long_word_end |
t | Find before the next character | find_till_char |
f | Find the next character | find_next_char |
T | Find after the previous character | till_prev_char |
F | Find the previous character | find_prev_char |
G | nG means go to line n , where n is a number | goto_line |
Alt-. | Repeat last cursor movement (f , t , m , etc.) | repeat_last_motion |
Home | Move to the start of the current line | goto_line_start |
End | Move to the end of the current line | goto_line_end |
Ctrl-b , PageUp | Scroll up a page | page_up |
Ctrl-f , PageDown | Scroll down a page | page_down |
Ctrl-u | Scroll up half a page | half_page_up |
Ctrl-d | Scroll down half a page | half_page_down |
Ctrl-i | Move to the next item in the jump list | jump_forward |
Ctrl-o | Move to the previous item in the jump list | jump_backward |
Ctrl-s | Save the current selection to the jump list | save_selection |
Text Modification#
Key | Description | Command |
---|---|---|
r | Replace with a character | replace |
R | Replace with yanked text | replace_with_yanked |
~ | Switch the case of selected text | switch_case |
` | Set selected text to lowercase | switch_to_lowercase |
Alt-` | Set selected text to uppercase | switch_to_uppercase |
i | Insert before selected content | insert_mode |
a | Insert after selected content (append) | append_mode |
I | Insert at the start of the current line | insert_at_line_start |
A | Insert at the end of the current line | insert_at_line_end |
o | Start a new line below selected content | open_below |
O | Start a new line above selected content | open_above |
. | Repeat last insert | N/A |
u | Undo modification | undo |
U | Redo modification | redo |
Alt-u | Go back to the previous history | earlier |
Alt-U | Go forward to the next history | later |
y | Copy selected content | yank |
p | Paste after selected content | paste_after |
P | Paste before selected content | paste_before |
" <reg> | Select a register to copy text to or paste from | select_register |
> | Indent selected content | indent |
< | Unindent selected content | unindent |
= | Format selected content (currently not available/disabled) (LSP) | format_selections |
d | Delete selected content | delete_selection |
Alt-d | Delete selected content without yanking it | delete_selection_noyank |
c | Change selected content (delete and enter insert mode) | change_selection |
Alt-c | Change selected content (delete and enter insert mode) without yanking it | change_selection_noyank |
Ctrl-a | Increment the number under the cursor | increment |
Ctrl-x | Decrement the number under the cursor | decrement |
Q | Start/stop recording a macro to the selected register (experimental feature) | record_macro |
q | Replay recorded macro from the selected register (experimental feature) | replay_macro |
Execute Shell Commands on Selection#
Key | Description | Command |
---|---|---|
` | ` | Pipe each selected content and replace it with the output of the shell command |
`Alt- | ` | Pipe each selected content and ignore the output of the shell command |
! | Run a shell command and insert its result before each selected content | shell_insert_output |
Alt-! | Run a shell command and insert its result after each selected content | shell_append_output |
$ | Pipe each selection to a shell command, keeping selections that return 0 | shell_keep_pipe |
Select Text#
Key | Description | Command |
---|---|---|
s | Select all regex matches within the selection range | select_regex |
S | Select content outside of regex matches within the selection range | split_selection |
Alt-s | Place a cursor at the end of each non-empty line in a multi-line selection | split_selection_on_newline |
& | Align selections by column (first use Alt-s ) | align_selections |
_ | Remove leading and trailing whitespace from the selection to shrink it | trim_selections |
; | Collapse the selection to the cursor (multi-cursor selections collapse to their respective cursors) | collapse_selection |
Alt-; | Reverse selection cursor and anchor (corresponds to Vim's o ) | flip_selections |
Alt-: | Ensure selections move forward in text direction (i.e., place all selection cursors at the end of the selection) | ensure_selections_forward |
, | Keep only the primary selection (collapse to the primary cursor in multi-cursor) | keep_primary_selection |
Alt-, | Remove the primary selection (remove the primary cursor in multi-cursor) | remove_primary_selection |
C | Copy selection to the next line (add a cursor at the same position down in multi-cursor) | copy_selection_on_next_line |
Alt-C | Copy selection to the previous line (add a cursor at the same position up in multi-cursor) | copy_selection_on_prev_line |
( | Make the previous selection the primary selection (move primary selection back) | rotate_selections_backward |
) | Make the next selection the primary selection (move primary selection forward) | rotate_selections_forward |
Alt-( | Replace each selection's content with the next selection's content (selection content moves back) | rotate_selection_contents_backward |
Alt-) | Replace each selection's content with the previous selection's content (selection content moves forward) | rotate_selection_contents_forward |
% | Select the entire file | select_all |
x | Select the current line; if already selected, extend to the next line | extend_line_below |
X | Extend the selection to line bounds and line-wise1 | extend_to_line_bounds |
Alt-x | Extend the selection to line bounds and line-wise | shrink_to_line_bounds |
J | Join lines within the selection with spaces | join_selections |
Alt-J | Join lines within the selection but use multi-cursor at the connection | join_selections_space |
K | Keep selections that match the regex within multi-selections | keep_selections |
Alt-K | Remove selections that match the regex within multi-selections | remove_selections |
Ctrl-c | Comment/uncomment selected content | toggle_comments |
Alt-o , Alt-up | Expand selected content to the parent syntax node (TS) | expand_selection |
Alt-i , Alt-down | Shrink selected content to the syntax node (TS) | shrink_selection |
Alt-p , Alt-left | Select the previous sibling node in the syntax tree (TS) | select_prev_sibling |
Alt-n , Alt-right | Select the next sibling node in the syntax tree (TS) | select_next_sibling |
╭─────╮ ╭─────╮ ╭─────╮
│text1│ <── backward ──│text0│── forward ──> │text1│
╰─────╯ ╰─────╯ ╰─────╯
╭─────╮
│text1│
╰─────╯
↑
backward: selection moves up/backward/reverse
|
╭─────╮
│text0│
╰─────╯
|
forward: selection moves down/forward/positive
↓
╭─────╮
│text1│
╰─────╯
<div class="hljs-button {2}" data-title="Copy"></div>
Search Text#
By default, search commands operate on the /
register. Use "<char>
to operate on different registers.
Key | Description | Command |
---|---|---|
/ | Forward regex search | search |
? | Backward regex search | rsearch |
n | Select the next matched search content (the selection will increase) | search_next |
N | Select the previous matched search content (the selection will increase) | search_prev |
* | Use the currently selected text as the search pattern | search_selection |
Minor Modes#
These sub-modes can be accessed from normal mode and typically switch back to normal mode after the command ends.
Key | Description | Command |
---|---|---|
v | Enter select (extend) mode | select_mode |
g | Enter goto mode | N/A |
m | Enter match mode | N/A |
: | Enter command mode | command_mode |
z | Enter view mode | N/A |
Z | Enter sticky view mode | N/A |
Ctrl-w | Enter window mode | N/A |
Space | Enter space mode | N/A |
View Mode#
View mode is used to scroll and manipulate the view without changing the selection.
This mode's sticky (press Z
) nature is persistent: you must use the Esc
key to return to normal mode. This is useful when you are just browsing text rather than actively editing it.
Key | Description | Command |
---|---|---|
z , c | Vertically center the current line | align_view_center |
t | Align the current line with the top of the screen | align_view_top |
b | Align the current line with the bottom of the screen | align_view_bottom |
m | Align the current line with the middle of the screen | align_view_middle |
j , down | Scroll the view down | scroll_down |
k , up | Scroll the view up | scroll_up |
Ctrl-f , PageDown | Scroll down a page | page_down |
Ctrl-b , PageUp | Scroll up a page | page_up |
Ctrl-d | Scroll down half a page | half_page_down |
Ctrl-u | Scroll up half a page | half_page_up |
Goto Mode#
Press g
to enter this mode to jump to different locations.
Key | Description | Command |
---|---|---|
g | Input gng to jump to line n2; if no number is input, jump to line 1 | goto_file_start |
e | Go to the last line | goto_last_line |
f | Go to the selected file3 | goto_file |
h | Go to the start of the current line | goto_line_start |
l | Go to the end of the current line | goto_line_end |
s | Go to the first non-whitespace character of the current line | goto_first_nonwhitespace |
t | Go to the top line of the screen | goto_window_top |
c | Go to the middle line of the screen | goto_window_center |
b | Go to the bottom line of the screen | goto_window_bottom |
d | Jump to definition (LSP) | goto_definition |
y | Jump to type definition (LSP) | goto_type_definition |
r | Jump to reference (LSP) | goto_reference |
i | Jump to implementation (LSP) | goto_implementation |
a | Go to the last accessed/alternative file | goto_last_accessed_file |
m | Go to the last modified/alternative file | goto_last_modified_file |
n | Go to the next buffer | goto_next_buffer |
p | Go to the previous buffer | goto_previous_buffer |
. | Go to the last modification in the current file | goto_last_modification |
Match Mode#
Enter this mode by pressing m
in normal mode. For explanations on surrounding and text objects, refer to the relevant sections in usage.
Key | Description | Command |
---|---|---|
m | Go to matching bracket (TS) | match_brackets |
s <char> | Surround the currently selected content with <char> | surround_add |
r <from><to> | Replace surrounding <from> characters with <to> | surround_replace |
d <char> | Delete surrounding <char> | surround_delete |
a <object> | Select text object around | select_textobject_around |
i <object> | Select inner text of the text object | select_textobject_inner |
TODO: Mappings for selecting syntax nodes (superset of [
).
Window Mode#
This part is similar to Vim key bindings since Kakoune does not support windows. Enter this mode by pressing <space>w
or <Ctrl-w>
.
Key | Description | Command |
---|---|---|
w , Ctrl-w | Switch to the next window | rotate_view |
v , Ctrl-v | Split vertically to the right | vsplit |
s , Ctrl-s | Split horizontally at the bottom | hsplit |
f | Go to the file in the selected content with horizontal split | goto_file |
F | Go to the file in the selected content with vertical split | goto_file |
h , Ctrl-h , Left | Move cursor to the left split window | jump_view_left |
j , Ctrl-j , Down | Move cursor to the bottom split window | jump_view_down |
k , Ctrl-k , Up | Move cursor to the top split window | jump_view_up |
l , Ctrl-l , Right | Move cursor to the right split window | jump_view_right |
q , Ctrl-q | Close the current window | wclose |
o , Ctrl-o | Keep only the current window, closing all other windows | wonly |
H | Swap the current window to the left4 | swap_view_left |
J | Swap the current window to the bottom | swap_view_down |
K | Swap the current window to the top | swap_view_up |
L | Swap the current window to the right | swap_view_right |
Space Mode#
This part is a haphazard mapping primarily for picker. Enter this mode by pressing <space>
.
Key | Description | Command |
---|---|---|
f | Open file picker | file_picker |
F | Open file picker in the current project directory | file_picker_in_current_directory |
b | Open buffer picker | buffer_picker |
j | Open jump list picker | jumplist_picker |
k | Show documentation for the item under the cursor in the popup box (LSP) | hover |
s | Open current document symbol picker (LSP) | symbol_picker |
S | Open workspace symbol picker (LSP) | workspace_symbol_picker |
g | Open current document code diagnostics picker (LSP) | diagnostics_picker |
G | Open workspace code diagnostics picker (LSP) | workspace_diagnostics_picker |
r | Rename symbol (LSP) | rename_symbol |
a | Perform code action (LSP) | code_action |
' | Open the last fuzzy picker | last_picker |
w | Enter window mode | N/A |
p | Paste the system clipboard content after the selection | paste_clipboard_after |
P | Paste the system clipboard content before the selection | paste_clipboard_before |
y | Copy selected text to clipboard | yank_joined_to_clipboard |
Y | (in multi-selection) Copy primary selection to clipboard | yank_main_selection_to_clipboard |
R | Replace selected text with the system clipboard text | replace_selections_with_clipboard |
/ | Perform a global search for text in the workspace folder | global_search |
? | Open command palette | command_palette |
Tip: Although global search uses command line input, it displays results in the fuzzy picker, so you can bring back the last search results after opening a file using
<space>'
.
Popup#
Display documentation for the item under the cursor.
Key | Description |
---|---|
Ctrl-u | Scroll up |
Ctrl-d | Scroll down |
Unimpaired#
Use vim-unimpaired style mappings for code navigation.
Key | Description | Command |
---|---|---|
[d | Go to the previous diagnostic (LSP) | goto_prev_diag |
]d | Go to the next diagnostic (LSP) | goto_next_diag |
[D | Go to the first diagnostic in this file (LSP) | goto_first_diag |
]D | Go to the last diagnostic in this file (LSP) | goto_last_diag |
]f | Go to the next function (TS) | goto_next_function |
[f | Go to the previous function (TS) | goto_prev_function |
]c | Go to the next class (TS) | goto_next_class |
[c | Go to the previous class (TS) | goto_prev_class |
]a | Go to the next parameter (TS) | goto_next_parameter |
[a | Go to the previous parameter (TS) | goto_prev_parameter |
]o | Go to the next comment (TS) | goto_next_comment |
[o | Go to the previous comment (TS) | goto_prev_comment |
]t | Go to the next test (TS) | goto_next_test |
]t | Go to the previous test (TS) | goto_prev_test |
]p | Go to the next paragraph | goto_next_paragraph |
[p | Go to the previous paragraph | goto_prev_paragraph |
[Space | Add a new line above | add_newline_above |
]Space | Add a new line below | add_newline_below |
Insert Mode#
By default, the keys bound in insert mode are minimal to some extent. Helix is designed as a modal editor, which is reflected in the user experience and internal mechanisms.
For example, changes made to the text are only saved for undo when exiting insert mode to normal mode. For this reason, new users are strongly encouraged to learn modal editing paradigms for the smoothest experience.
Key | Description | Command |
---|---|---|
Escape | Switch to normal mode | normal_mode |
Ctrl-s | Commit undo checkpoint | commit_undo_checkpoint |
Ctrl-x | Autocomplete | completion |
Ctrl-r | Insert content from register | insert_register |
Ctrl-w , Alt-Backspace | Delete the previous word | delete_word_backward |
Alt-d , Alt-Delete | Delete the next word | delete_word_forward |
Ctrl-u | Delete to the start of the line | kill_to_line_start |
Ctrl-k | Delete to the end of the line | kill_to_line_end |
Ctrl-h , Backspace | Delete the previous character | delete_char_backward |
Ctrl-d , Delete | Delete the next character | delete_char_forward |
Ctrl-j , Enter | Insert a new line | insert_newline |
These shortcuts are not recommended; they are provided just for users who are less familiar with modal editors.
If you wish to disable them while in insert mode for a more modal editing experience, use the following command in config.toml
:
[keys.insert]
up = "no_op"
down = "no_op"
left = "no_op"
right = "no_op"
pageup = "no_op"
pagedown = "no_op"
home = "no_op"
end = "no_op"
<div class="hljs-button {2}" data-title="Copy"></div>
Select / Extend Mode#
Press v
to enter and exit this mode, which is similar to normal mode but changes arbitrary movements to extend the selection instead of replacing it. Goto movements are also changed to extend; for example, vgl
will extend the selection to the end of the line.
Search is also affected. By default, n
and N
will remove the current selection and select the next instance of the search term.
Switching to this mode before pressing n
or N
can keep the current selection. Opening and closing this mode during iterative searches allows you to selectively add search items to the selection.5
Picker#
Keys used in the picker. Currently, remapping of these keys is not supported.
Key | Description |
---|---|
Shift-Tab , Up , Ctrl-p | Previous item |
Tab , Down , Ctrl-n | Next item |
PageUp , Ctrl-u | Scroll up |
PageDown , Ctrl-d | Scroll down |
Home | Go to the first item |
End | Go to the last item |
Enter | Open the selected item |
Ctrl-s | Open in a vertically split window |
Ctrl-v | Open in a horizontally split window |
Ctrl-t | Toggle preview |
Escape , Ctrl-c | Close the picker |
Prompt#
Keys used in the prompt (for example, when pressing s
to bring up the input location in the command line), currently remapping of these keys is not supported.
Key | Description |
---|---|
Escape , Ctrl-c | Close the prompt |
Alt-b , Ctrl-Left | Go to the previous word (normal mode's b ) |
Ctrl-b , Left | Go to the previous character (normal mode's h ) |
Alt-f , Ctrl-Right | Go to the next word |
Ctrl-f , Right | Go to the next character |
Ctrl-e , End | Go to the end of the line |
Ctrl-a , Home | Go to the start of the line |
Ctrl-w , Alt-Backspace , Ctrl-Backspace | Delete the previous word |
Alt-d , Alt-Delete , Ctrl-Delete | Delete the next word |
Ctrl-u | Delete to the start of the line |
Ctrl-k | Delete to the end of the line |
Backspace , Ctrl-h | Delete the previous character |
Delete , Ctrl-d | Delete the next character |
Ctrl-s | Insert a space under the cursor, may change to Ctrl-r Ctrl-w later |
Ctrl-p , Up | Select the previous history |
Ctrl-n , Down | Select the next history |
Ctrl-r | Insert content from the selected register |
Tab | Select the next completion item |
BackTab | Select the previous completion item |
Enter | Open the selected item |
-
Translator's note: The difference between
X
andx
is that when extending across lines,x
always places the cursor at the end, whileX
senses the direction of the selection, which is called
line-wise: If the cursor is in the downward direction of the selection, then the cursor will be at the end after the selection extends; if the cursor is in the upward direction of the selection, then the cursor will be at the end after the selection extends.
For understanding the direction of the selection, you can refer to my understanding: ↩︎ -
gng
is equivalent tongg
andnG
, both used to jump to line n. ↩︎ -
gf
treats the selected content as a file path (can be relative or absolute); when the path does not exist, it opens a buffer for that path, writing creates the file (not writing does not create). ↩︎