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
Navigation
| Key | Action |
|---|---|
↑ / Ctrl+k / Ctrl+p | Move up |
↓ / Ctrl+j / Ctrl+n | Move down |
Page Up | Scroll up |
Page Down | Scroll down |
Home | First item |
End | Last item |
Query Editing
| Key | Action |
|---|---|
Ctrl+u | Clear query |
Ctrl+w | Delete previous word |
Ctrl+a | Start of query |
Ctrl+e | End of query |
Alt+f | Forward one word |
Alt+b | Backward one word |
Selection
| Key | Action |
|---|---|
Enter | Accept (output selected) |
Esc / Ctrl+c | Cancel (exit 130) |
Tab | Toggle mark (multi-select) |
Shift+Tab | Toggle mark backwards |
Ctrl+A | Select all |
Ctrl+D | Deselect all |
Preview
| Key | Action |
|---|---|
Shift+↑ | Scroll preview up |
Shift+↓ | Scroll preview down |
(custom) Ctrl+/ | Toggle preview |
(custom) Ctrl+u | Half page up in preview |
(custom) Ctrl+d | Half page down in preview |
Essential CLI Flags
| Flag | Description |
|---|---|
-m / --multi | Multi-select (Tab to mark) |
--multi=N | Multi-select up to N items |
-q / --query "str" | Pre-fill query |
-1 / --select-1 | Auto-select if one match |
-0 / --exit-0 | Exit immediately if no match |
-f / --filter "str" | Non-interactive batch mode |
--height N% | Partial screen height |
--reverse | Query at top |
--prompt "str" | Custom prompt text |
--header "str" | Header text |
--header-lines=N | Freeze first N input lines as header |
--preview 'cmd {}' | Preview command |
--preview-window POS:SIZE | Preview position and size |
--border | Border style |
--bind KEY:ACTION | Custom key binding |
--expect KEY,KEY | Capture alternative keys |
--with-nth N | Display only certain fields |
--nth N | Search only certain fields |
--delimiter STR | Field delimiter |
--no-sort | Keep input order |
--tiebreak OPTS | Tiebreak order |
-i | Case insensitive always |
+i | Case sensitive always |
--ansi | Enable ANSI color in input |
--print0 | Null-delimited output |
--read0 | Null-delimited input |
--print-query | Output query before selection |
--tmux OPTS | Run 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
| Variable | Controls |
|---|---|
FZF_DEFAULT_COMMAND | Default input command |
FZF_DEFAULT_OPTS | Default flags (applies to all fzf) |
FZF_CTRL_T_COMMAND | Input for CTRL-T |
FZF_CTRL_T_OPTS | Options for CTRL-T |
FZF_CTRL_R_OPTS | Options for CTRL-R |
FZF_ALT_C_COMMAND | Input for ALT-C |
FZF_ALT_C_OPTS | Options for ALT-C |
FZF_COMPLETION_TRIGGER | Trigger for ** completion (default: **) |
FZF_COMPLETION_OPTS | Options for completion |
FZF_PREVIEW_COLUMNS | Width of preview window (in preview cmd) |
FZF_PREVIEW_LINES | Height of preview window (in preview cmd) |
Placeholder Tokens in --preview and --bind
| Token | Expands 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
| Code | Meaning |
|---|---|
0 | Successfully selected |
1 | No match or empty selection |
2 | Error |
130 | Aborted (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