Cheatsheet

One-page keystroke reference: modes, motions, operators, git, LSP.

On this page

Normal mode

KeyAction
h j k lMove cursor
w b eWord motions
0 ^ $Line start / first non-whitespace / line end
f{char} F{char}Find forward / backward on line
t{char} T{char}Until forward / backward on line
%Matching bracket
gg GFirst line / last line
{N}gg {N}GGo to line N
/ ?Search forward / backward
n NNext / previous match
* #Search word under cursor forward / backward

Operators

KeyAction
d{motion}Delete
c{motion}Change (delete + enter insert)
y{motion}Yank (copy)
~Toggle case
gu{motion}Lowercase
gU{motion}Uppercase
> {motion}Indent right
< {motion}Indent left
=Format (lsp-format or ={motion})
gq{motion}Format / hard-wrap

Text objects

KeySelects
iw awInner / a word
iW aWInner / a WORD (non-whitespace)
is asInner / a sentence
ip apInner / a paragraph
it atInner / a tag block (HTML/XML)
i( a(Inner / a paren block
i{ a{Inner / a brace block
i[ a[Inner / a bracket block
i< a<Inner / a angle bracket block
i' a'Inner / a single-quoted string
i" a"Inner / a double-quoted string
i\`` a``Inner / a backtick-quoted string

Counts

Prefix motions and operators with a number: 3j (down 3), d5w (delete 5 words).

Visual mode

KeyAction
vCharacter-wise visual
VLine-wise visual
<C-v>Block-wise visual
oMove cursor to other end of selection
d xDelete selection
cChange selection
yYank selection
~Toggle case
> <Indent / outdent

Insert mode

KeyAction
<Esc>Return to normal
<C-h>Delete character before cursor
<C-w>Delete word before cursor
<C-u>Delete to start of line
<C-r>{reg}Insert from register
<C-n> <C-p>Completion next / previous
<C-e>Cancel completion

Command-line mode (:)

CommandAction
:wWrite (save)
:qQuit current buffer
:wqWrite and quit
:q!Force quit (discard changes)
:e {file}Open file
:bn :bpNext / previous buffer
:lsList buffers
:bdDelete buffer
:split :vsplitSplit horizontal / vertical
:tabnewNew tab
:set {option}Set option
:colorscheme {name}Change theme
:{range}s/old/new/gSubstitute
:g/pattern/commandGlobal command
:help {topic}Open help

Picker

CommandOpens
:picker {source}A named source (files, recent, buffers, lines, outline, grep, jumps, marks, registers, commands, colorscheme, ...); <Tab> after :picker lists them
:files [root]File picker
:recentRecently-edited files
:buffers :bBuffer switcher
:colorschemeTheme picker, with live preview

Picker (within picker)

KeyAction
<C-n> <Down> <Tab>Next result
<C-p> <Up> <S-Tab>Previous result
<CR>Accept selected candidate
<Esc> <C-c>Dismiss picker
<C-s>Accept, open in horizontal split
<C-v>Accept, open in vertical split
<C-t>Accept, open in new tab

Multibuffer / search results

KeyAction
:search {pattern}Search project
<CR>Jump to source location
]e [eNext / previous match
grRefresh (re-run the same search)

Diff mode

KeyAction
:diffthisStart diff
]c [cNext / previous hunk
doDiff obtain (get from other buffer)
dpDiff put (put to other buffer)

Buffers and navigation

KeyAction
<C-w> h/j/k/lNavigate panes
<C-w> wCycle panes
<C-w> s/vSplit horizontal / vertical
<C-w> cClose pane
:onlyClose every pane except the active one

LSP

KeyCommandAction
KShow hover documentation
gdGo to definition
gDGo to declaration
gIGo to implementation (lowercase gi is vim's "go to last insert")
grFind references (picker)
[d ]d:diag-prev / :diag-nextPrevious / next diagnostic
:lsp-referencesOpen the editable references view
:lsp-renameRename symbol
:lsp-formatFormat buffer

Macros

KeyAction
q{reg}Start recording into register
q (in recording)Stop recording
@{reg}Execute macro
{N}@{reg}Execute macro N times
@@Repeat last macro

Registers

RegisterContent
"Unnamed (default yank/delete)
0Last yank
1-9Last 9 deletes
a-zNamed registers
+ *System clipboard
_Black hole (discards)

Marks

KeyAction
m{a-z}Set mark
'{a-z}Jump to mark line
`{a-z}Jump to mark line + column
<C-o> <C-i>Walk the jump list back / forward

Options

OptionDefaultDescription
tabstop4Spaces per tab
shiftwidth4Spaces per indent
expandtabtrueUse spaces for tabs
numbertrueShow line numbers
relativenumberfalseShow relative line numbers
wrapfalseSoft-wrap long lines
scrolloff0Lines visible above/below cursor
sidescrolloff0Columns visible left/right of cursor
ui.mousetrueMouse support
clipboardtrueYank/paste through the system clipboard (bool, not vim's unnamed string)

See also