banner
huqingye

huqingye

Helix Key Mapping (Turn)

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, and T are not limited to the current line.

KeyDescriptionCommand
h, LeftMove leftmove_char_left
j, DownMove downmove_line_down
k, UpMove upmove_line_up
l, RightMove rightmove_char_right
wMove to the start of the next wordmove_next_word_start
bMove to the start of the previous wordmove_prev_word_start
eMove to the end of the next wordmove_next_word_end
WMove to the start of the next WORDmove_next_long_word_start
BMove to the end of the previous WORDmove_prev_long_word_start
EMove to the end of the next WORDmove_next_long_word_end
tFind before the next characterfind_till_char
fFind the next characterfind_next_char
TFind after the previous charactertill_prev_char
FFind the previous characterfind_prev_char
GnG means go to line n, where n is a numbergoto_line
Alt-.Repeat last cursor movement (f, t, m, etc.)repeat_last_motion
HomeMove to the start of the current linegoto_line_start
EndMove to the end of the current linegoto_line_end
Ctrl-b, PageUpScroll up a pagepage_up
Ctrl-f, PageDownScroll down a pagepage_down
Ctrl-uScroll up half a pagehalf_page_up
Ctrl-dScroll down half a pagehalf_page_down
Ctrl-iMove to the next item in the jump listjump_forward
Ctrl-oMove to the previous item in the jump listjump_backward
Ctrl-sSave the current selection to the jump listsave_selection

Text Modification#

KeyDescriptionCommand
rReplace with a characterreplace
RReplace with yanked textreplace_with_yanked
~Switch the case of selected textswitch_case
`Set selected text to lowercaseswitch_to_lowercase
Alt-`Set selected text to uppercaseswitch_to_uppercase
iInsert before selected contentinsert_mode
aInsert after selected content (append)append_mode
IInsert at the start of the current lineinsert_at_line_start
AInsert at the end of the current lineinsert_at_line_end
oStart a new line below selected contentopen_below
OStart a new line above selected contentopen_above
.Repeat last insertN/A
uUndo modificationundo
URedo modificationredo
Alt-uGo back to the previous historyearlier
Alt-UGo forward to the next historylater
yCopy selected contentyank
pPaste after selected contentpaste_after
PPaste before selected contentpaste_before
" <reg>Select a register to copy text to or paste fromselect_register
>Indent selected contentindent
<Unindent selected contentunindent
=Format selected content (currently not available/disabled) (LSP)format_selections
dDelete selected contentdelete_selection
Alt-dDelete selected content without yanking itdelete_selection_noyank
cChange selected content (delete and enter insert mode)change_selection
Alt-cChange selected content (delete and enter insert mode) without yanking itchange_selection_noyank
Ctrl-aIncrement the number under the cursorincrement
Ctrl-xDecrement the number under the cursordecrement
QStart/stop recording a macro to the selected register (experimental feature)record_macro
qReplay recorded macro from the selected register (experimental feature)replay_macro
Execute Shell Commands on Selection#
KeyDescriptionCommand
``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 contentshell_insert_output
Alt-!Run a shell command and insert its result after each selected contentshell_append_output
$Pipe each selection to a shell command, keeping selections that return 0shell_keep_pipe

Select Text#

KeyDescriptionCommand
sSelect all regex matches within the selection rangeselect_regex
SSelect content outside of regex matches within the selection rangesplit_selection
Alt-sPlace a cursor at the end of each non-empty line in a multi-line selectionsplit_selection_on_newline
&Align selections by column (first use Alt-s)align_selections
_Remove leading and trailing whitespace from the selection to shrink ittrim_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
CCopy selection to the next line (add a cursor at the same position down in multi-cursor)copy_selection_on_next_line
Alt-CCopy 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 fileselect_all
xSelect the current line; if already selected, extend to the next lineextend_line_below
XExtend the selection to line bounds and line-wise1extend_to_line_bounds
Alt-xExtend the selection to line bounds and line-wiseshrink_to_line_bounds
JJoin lines within the selection with spacesjoin_selections
Alt-JJoin lines within the selection but use multi-cursor at the connectionjoin_selections_space
KKeep selections that match the regex within multi-selectionskeep_selections
Alt-KRemove selections that match the regex within multi-selectionsremove_selections
Ctrl-cComment/uncomment selected contenttoggle_comments
Alt-o, Alt-upExpand selected content to the parent syntax node (TS)expand_selection
Alt-i, Alt-downShrink selected content to the syntax node (TS)shrink_selection
Alt-p, Alt-leftSelect the previous sibling node in the syntax tree (TS)select_prev_sibling
Alt-n, Alt-rightSelect the next sibling node in the syntax tree (TS)select_next_sibling
╭─────╮                ╭─────╮               ╭─────╮
│text1│ &lt;── backward ──│text0│── forward ──&gt; │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.

KeyDescriptionCommand
/Forward regex searchsearch
?Backward regex searchrsearch
nSelect the next matched search content (the selection will increase)search_next
NSelect the previous matched search content (the selection will increase)search_prev
*Use the currently selected text as the search patternsearch_selection

Minor Modes#

These sub-modes can be accessed from normal mode and typically switch back to normal mode after the command ends.

KeyDescriptionCommand
vEnter select (extend) modeselect_mode
gEnter goto modeN/A
mEnter match modeN/A
:Enter command modecommand_mode
zEnter view modeN/A
ZEnter sticky view modeN/A
Ctrl-wEnter window modeN/A
SpaceEnter space modeN/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.

KeyDescriptionCommand
z, cVertically center the current linealign_view_center
tAlign the current line with the top of the screenalign_view_top
bAlign the current line with the bottom of the screenalign_view_bottom
mAlign the current line with the middle of the screenalign_view_middle
j, downScroll the view downscroll_down
k, upScroll the view upscroll_up
Ctrl-f, PageDownScroll down a pagepage_down
Ctrl-b, PageUpScroll up a pagepage_up
Ctrl-dScroll down half a pagehalf_page_down
Ctrl-uScroll up half a pagehalf_page_up
Goto Mode#

Press g to enter this mode to jump to different locations.

KeyDescriptionCommand
gInput gng to jump to line n2; if no number is input, jump to line 1goto_file_start
eGo to the last linegoto_last_line
fGo to the selected file3goto_file
hGo to the start of the current linegoto_line_start
lGo to the end of the current linegoto_line_end
sGo to the first non-whitespace character of the current linegoto_first_nonwhitespace
tGo to the top line of the screengoto_window_top
cGo to the middle line of the screengoto_window_center
bGo to the bottom line of the screengoto_window_bottom
dJump to definition (LSP)goto_definition
yJump to type definition (LSP)goto_type_definition
rJump to reference (LSP)goto_reference
iJump to implementation (LSP)goto_implementation
aGo to the last accessed/alternative filegoto_last_accessed_file
mGo to the last modified/alternative filegoto_last_modified_file
nGo to the next buffergoto_next_buffer
pGo to the previous buffergoto_previous_buffer
.Go to the last modification in the current filegoto_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.

KeyDescriptionCommand
mGo 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 aroundselect_textobject_around
i <object>Select inner text of the text objectselect_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>.

KeyDescriptionCommand
w, Ctrl-wSwitch to the next windowrotate_view
v, Ctrl-vSplit vertically to the rightvsplit
s, Ctrl-sSplit horizontally at the bottomhsplit
fGo to the file in the selected content with horizontal splitgoto_file
FGo to the file in the selected content with vertical splitgoto_file
h, Ctrl-h, LeftMove cursor to the left split windowjump_view_left
j, Ctrl-j, DownMove cursor to the bottom split windowjump_view_down
k, Ctrl-k, UpMove cursor to the top split windowjump_view_up
l, Ctrl-l, RightMove cursor to the right split windowjump_view_right
q, Ctrl-qClose the current windowwclose
o, Ctrl-oKeep only the current window, closing all other windowswonly
HSwap the current window to the left4swap_view_left
JSwap the current window to the bottomswap_view_down
KSwap the current window to the topswap_view_up
LSwap the current window to the rightswap_view_right
Space Mode#

This part is a haphazard mapping primarily for picker. Enter this mode by pressing <space>.

KeyDescriptionCommand
fOpen file pickerfile_picker
FOpen file picker in the current project directoryfile_picker_in_current_directory
bOpen buffer pickerbuffer_picker
jOpen jump list pickerjumplist_picker
kShow documentation for the item under the cursor in the popup box (LSP)hover
sOpen current document symbol picker (LSP)symbol_picker
SOpen workspace symbol picker (LSP)workspace_symbol_picker
gOpen current document code diagnostics picker (LSP)diagnostics_picker
GOpen workspace code diagnostics picker (LSP)workspace_diagnostics_picker
rRename symbol (LSP)rename_symbol
aPerform code action (LSP)code_action
'Open the last fuzzy pickerlast_picker
wEnter window modeN/A
pPaste the system clipboard content after the selectionpaste_clipboard_after
PPaste the system clipboard content before the selectionpaste_clipboard_before
yCopy selected text to clipboardyank_joined_to_clipboard
Y(in multi-selection) Copy primary selection to clipboardyank_main_selection_to_clipboard
RReplace selected text with the system clipboard textreplace_selections_with_clipboard
/Perform a global search for text in the workspace folderglobal_search
?Open command palettecommand_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.

KeyDescription
Ctrl-uScroll up
Ctrl-dScroll down
Unimpaired#

Use vim-unimpaired style mappings for code navigation.

KeyDescriptionCommand
[dGo to the previous diagnostic (LSP)goto_prev_diag
]dGo to the next diagnostic (LSP)goto_next_diag
[DGo to the first diagnostic in this file (LSP)goto_first_diag
]DGo to the last diagnostic in this file (LSP)goto_last_diag
]fGo to the next function (TS)goto_next_function
[fGo to the previous function (TS)goto_prev_function
]cGo to the next class (TS)goto_next_class
[cGo to the previous class (TS)goto_prev_class
]aGo to the next parameter (TS)goto_next_parameter
[aGo to the previous parameter (TS)goto_prev_parameter
]oGo to the next comment (TS)goto_next_comment
[oGo to the previous comment (TS)goto_prev_comment
]tGo to the next test (TS)goto_next_test
]tGo to the previous test (TS)goto_prev_test
]pGo to the next paragraphgoto_next_paragraph
[pGo to the previous paragraphgoto_prev_paragraph
[SpaceAdd a new line aboveadd_newline_above
]SpaceAdd a new line belowadd_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.

KeyDescriptionCommand
EscapeSwitch to normal modenormal_mode
Ctrl-sCommit undo checkpointcommit_undo_checkpoint
Ctrl-xAutocompletecompletion
Ctrl-rInsert content from registerinsert_register
Ctrl-w, Alt-BackspaceDelete the previous worddelete_word_backward
Alt-d, Alt-DeleteDelete the next worddelete_word_forward
Ctrl-uDelete to the start of the linekill_to_line_start
Ctrl-kDelete to the end of the linekill_to_line_end
Ctrl-h, BackspaceDelete the previous characterdelete_char_backward
Ctrl-d, DeleteDelete the next characterdelete_char_forward
Ctrl-j, EnterInsert a new lineinsert_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.

KeyDescription
Shift-Tab, Up, Ctrl-pPrevious item
Tab, Down, Ctrl-nNext item
PageUp, Ctrl-uScroll up
PageDown, Ctrl-dScroll down
HomeGo to the first item
EndGo to the last item
EnterOpen the selected item
Ctrl-sOpen in a vertically split window
Ctrl-vOpen in a horizontally split window
Ctrl-tToggle preview
Escape, Ctrl-cClose 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.

KeyDescription
Escape, Ctrl-cClose the prompt
Alt-b, Ctrl-LeftGo to the previous word (normal mode's b)
Ctrl-b, LeftGo to the previous character (normal mode's h)
Alt-f, Ctrl-RightGo to the next word
Ctrl-f, RightGo to the next character
Ctrl-e, EndGo to the end of the line
Ctrl-a, HomeGo to the start of the line
Ctrl-w, Alt-Backspace, Ctrl-BackspaceDelete the previous word
Alt-d, Alt-Delete, Ctrl-DeleteDelete the next word
Ctrl-uDelete to the start of the line
Ctrl-kDelete to the end of the line
Backspace, Ctrl-hDelete the previous character
Delete, Ctrl-dDelete the next character
Ctrl-sInsert a space under the cursor, may change to Ctrl-r Ctrl-w later
Ctrl-p, UpSelect the previous history
Ctrl-n, DownSelect the next history
Ctrl-rInsert content from the selected register
TabSelect the next completion item
BackTabSelect the previous completion item
EnterOpen the selected item

  1. Translator's note: The difference between X and x is that when extending across lines, x always places the cursor at the end, while X 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: ↩︎

  2. gng is equivalent to ngg and nG, both used to jump to line n. ↩︎

  3. 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). ↩︎

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.