Helix cheatsheet

· Tech

A quick reference for my Helix setup. Default keybindings plus my custom ones (C-s, C-q, C-/, C-r).

Move around

KeyAction
h j k lLeft / down / up / right
w / bNext / prev word
eEnd of word
W / BNext / prev WORD (with punct)
gg / geStart / end of file
gh / glStart / end of line
gsFirst non-blank char
C-u / C-dHalf page up / down
C-b / C-fFull page up / down
f{c} / F{c}Jump to char fwd / back
t{c} / T{c}Jump before char fwd / back
{num}ggJump to line number
C-o / C-iJump history back / fwd
mmJump to matching bracket
gwWord jump (labels on screen)
]f / [fNext / prev function
]c / [cNext / prev class
]d / [dNext / prev diagnostic
]p / [pNext / prev paragraph

Scroll view (z)

KeyAction
zc / zzCenter cursor on screen
zt / zbScroll cursor to top / bottom
zk / zjScroll up / down one line

Select

KeyAction
vEnter/extend selection mode
xSelect entire line
X / xxExtend selection by lines
%Select entire file
;Collapse selection to cursor
,Clear extra cursors
Alt+;Flip selection direction
_Trim whitespace from selection

Select objects (m)

KeyAction
mi( mi{ mi[Inside brackets
ma( ma{ ma[Around brackets
mi" / mi'Inside quotes
ma" / ma'Around quotes
miw / mawInside / around word
mif / mafInside / around function
mic / macInside / around class
mip / mapInside / around paragraph

Select with syntax tree

KeyAction
Alt+oExpand selection (syntax)
Alt+iShrink selection (syntax)
Alt+n / Alt+pNext / prev sibling node

Multi-cursor

KeyAction
CAdd cursor on line below
Alt+CAdd cursor on line above
sSearch regex in selection
SSplit selection by regex
Alt+sSplit selection into lines
&Align cursors to column

Edit

KeyAction
i / aInsert before / after cursor
I / AInsert at line start / end
o / ONew line below / above
dDelete selection
cChange (delete + insert)
yYank (copy)
p / PPaste after / before
RReplace from clipboard
r{c}Replace selection with char
~Toggle case
JJoin lines
> / <Indent / outdent
=Auto-format selection (LSP)
C-a / C-xIncrement / decrement number
C-/Toggle line comment (custom)

Undo and macros

KeyAction
u / UUndo / redo
QRecord / stop recording macro
qPlay macro

Search and replace

KeyAction
/Search forward
?Search backward
n / NNext / prev match
*Search word under cursor
:s/a/b/gReplace in selection
:%s/a/b/gReplace in entire file

Find files and symbols (Space)

KeyAction
Space+eFile explorer (directory tree)
Space+fFile picker (fuzzy search)
Space+FFile picker in CWD
Space+bBuffer picker (open files)
Space+jJumplist picker
Space+sSymbol picker (functions, types)
Space+SWorkspace symbol picker
Space+/Global search (grep project)
Space+?Command palette

Code intelligence (LSP)

KeyAction
gdGo to definition
grGo to references
giGo to implementation
gyGo to type definition
gaGo to last accessed file
Space+hHover docs
Space+kSignature help
Space+aCode action (fix, import)
Space+rRename symbol (refactor)
Space+dDiagnostics (errors list)
Space+DWorkspace diagnostics

Windows and splits

KeyAction
C-w s / :hsplitSplit horizontal
C-w v / :vsplitSplit vertical
C-w h/j/k/lFocus left/down/up/right
C-w wCycle through windows
C-w qClose current window
C-w oClose all other windows

Files and buffers

KeyAction
:wSave (+ auto-format if on)
:q / :q!Quit / force quit
:wq / :wqaSave+quit / all
:o {path}Open or create file
:bcClose current buffer
:bn / :bpNext / prev buffer
:sh mkdir -p dirCreate dirs from hx
C-sSave (custom)
C-qQuit (custom)
C-rReload all buffers (custom)

Useful commands (:)

KeyAction
:sh {cmd}Run shell command
:formatFormat entire file
:pipe {cmd}Pipe selection through cmd
:config-reloadReload .toml config
:lsp-restartRestart LSP server
:theme {name}Switch color theme
:set line-numbers relRelative line numbers
:tutorBuilt-in tutorial

Registers and clipboard

KeyAction
"ay / "apYank / paste register a
"+y / "+pSystem clipboard copy / paste
"_dDelete without yanking

Insert mode

KeyAction
C-xTrigger autocomplete
C-wDelete word backward
C-uDelete to start of line
C-rInsert from register
EscBack to normal mode

Common recipes

SequenceResult
xdDelete line
xyYank (copy) line
miw cChange word
mi{ cChange inside
% s{pat} cFind and replace in file
x s{pat} cReplace in selected lines
v+move d...pCut block, move, paste
x(repeat) C-/Comment multiple lines
gd Space+rGo to def + rename symbol