Skip to main content

fzf Cheatsheet

Search Syntax

TERM        Fuzzy match (chars in order, any spacing)
'TERM Exact substring match
^TERM Prefix exact (starts with)
TERM$ Suffix exact (ends with)
^TERM$ Full-line exact match
!TERM NOT fuzzy
!'TERM NOT exact
!^TERM Does NOT start with
!TERM$ Does NOT end with

TERM1 TERM2 AND: both must match
TERM1 | TERM2 OR: either matches

Default Key Bindings

KeyAction
/ Ctrl+k / Ctrl+pMove up
/ Ctrl+j / Ctrl+nMove down
Page UpScroll up
Page DownScroll down
HomeFirst item
EndLast item

Query Editing

KeyAction
Ctrl+uClear query
Ctrl+wDelete previous word
Ctrl+aStart of query
Ctrl+eEnd of query
Alt+fForward one word
Alt+bBackward one word

Selection

KeyAction
EnterAccept (output selected)
Esc / Ctrl+cCancel (exit 130)
TabToggle mark (multi-select)
Shift+TabToggle mark backwards
Ctrl+ASelect all
Ctrl+DDeselect all

Preview

KeyAction
Shift+↑Scroll preview up
Shift+↓Scroll preview down
(custom) Ctrl+/Toggle preview
(custom) Ctrl+uHalf page up in preview
(custom) Ctrl+dHalf page down in preview

Essential CLI Flags

FlagDescription
-m / --multiMulti-select (Tab to mark)
--multi=NMulti-select up to N items
-q / --query "str"Pre-fill query
-1 / --select-1Auto-select if one match
-0 / --exit-0Exit immediately if no match
-f / --filter "str"Non-interactive batch mode
--height N%Partial screen height
--reverseQuery at top
--prompt "str"Custom prompt text
--header "str"Header text
--header-lines=NFreeze first N input lines as header
--preview 'cmd {}'Preview command
--preview-window POS:SIZEPreview position and size
--borderBorder style
--bind KEY:ACTIONCustom key binding
--expect KEY,KEYCapture alternative keys
--with-nth NDisplay only certain fields
--nth NSearch only certain fields
--delimiter STRField delimiter
--no-sortKeep input order
--tiebreak OPTSTiebreak order
-iCase insensitive always
+iCase sensitive always
--ansiEnable ANSI color in input
--print0Null-delimited output
--read0Null-delimited input
--print-queryOutput query before selection
--tmux OPTSRun as tmux popup

Preview Window Options

--preview-window=right:60%     → right side, 60% width
--preview-window=down:20 → bottom, 20 lines
--preview-window=hidden → start hidden (toggle with bind)
--preview-window=wrap → wrap long lines
--preview-window=+{2}/2 → scroll to field 2, centered

--bind Actions Reference

accept               → confirm selection
abort → cancel
toggle → toggle multi-select mark
select-all → mark all
deselect-all → unmark all
toggle-preview → show/hide preview
preview-up/down → scroll preview
preview-half-page-up/down → half-page scroll preview
reload(cmd) → reload list from command
execute(cmd) → run command (stay in fzf)
execute-silent(cmd) → run silently
become(cmd) → replace fzf with command
change-preview(cmd) → change preview command
transform(cmd) → transform fzf options
change-prompt(str) → change prompt
change-header(str) → change header
put(str) → insert string into query
replace-query → replace query with item
clear-query → clear query
jump → EasyMotion-style jump labels

Environment Variables

VariableControls
FZF_DEFAULT_COMMANDDefault input command
FZF_DEFAULT_OPTSDefault flags (applies to all fzf)
FZF_CTRL_T_COMMANDInput for CTRL-T
FZF_CTRL_T_OPTSOptions for CTRL-T
FZF_CTRL_R_OPTSOptions for CTRL-R
FZF_ALT_C_COMMANDInput for ALT-C
FZF_ALT_C_OPTSOptions for ALT-C
FZF_COMPLETION_TRIGGERTrigger for ** completion (default: **)
FZF_COMPLETION_OPTSOptions for completion
FZF_PREVIEW_COLUMNSWidth of preview window (in preview cmd)
FZF_PREVIEW_LINESHeight of preview window (in preview cmd)

Placeholder Tokens in --preview and --bind

TokenExpands to
{}Currently highlighted item
{1}, {2}, {N}Nth field (using delimiter)
{-1}Last field
{1..}Fields from 1 onwards
{..3}Fields up to 3
{1..3}Fields 1 to 3
{q}Current query string
{n}Line number (0-based)
{+}All selected items (multi)

Exit Codes

CodeMeaning
0Successfully selected
1No match or empty selection
2Error
130Aborted (Esc / Ctrl+c)

Quick Pattern Reference

# Open file
nvim $(fzf)

# Multi-select files
vim $(fzf -m)

# Preview with bat
fzf --preview 'bat --color=always {}'

# Live grep
rg --color=always -n '' | fzf --ansi --delimiter=: \
--preview 'bat --color=always --highlight-line={2} {1}' \
--preview-window '+{2}/2'

# Git branch checkout
git branch | fzf | xargs git checkout

# Kill process
ps aux | fzf | awk '{print $2}' | xargs kill

# SSH to host
grep -E "^Host " ~/.ssh/config | awk '{print $2}' | fzf | xargs ssh

Back to Start