Vim keyboard shortcuts

Vim is the modal text editor found on virtually every Unix system, built around composable commands instead of chorded shortcuts. Its keys are identical on every platform, which is why Vim muscle memory follows you to any server or editor with a Vim mode. These are the core default commands in Normal mode unless noted. This cheat sheet covers 88 default shortcuts for Windows and Mac.

Modes

Insert before cursorii
Insert at start of lineII
Append after cursoraa
Append at end of lineAA
Open new line belowoo
Open new line aboveOO
Visual mode (character)vv
Visual line modeVV
Visual block modeCtrl+VCtrl+V
Replace modeRR
Return to Normal modeEscEsc
Command-line mode::

Basic Movement

Move left / down / up / righth / j / k / lh / j / k / l
Next word startww
Previous word startbb
End of wordee
Start of line00
First non-blank character of line^^
End of line$$
First line of filegggg
Last line of fileGG
Go to line NNGNG
Next paragraph / block}}
Previous paragraph / block{{
Jump to matching bracket%%

Scrolling & Screen

Scroll half page downCtrl+DCtrl+D
Scroll half page upCtrl+UCtrl+U
Scroll full page downCtrl+FCtrl+F
Scroll full page upCtrl+BCtrl+B
Top of screenHH
Middle of screenMM
Bottom of screenLL
Center current line on screenzzzz

In-Line Search

Find character forward in linef{char}f{char}
Find character backward in lineF{char}F{char}
Move till before charactert{char}t{char}
Repeat last f/t motion;;
Repeat last f/t motion backward,,

Editing

Delete character under cursorxx
Delete linedddd
Delete worddwdw
Delete to end of lineDD
Change word (delete and insert)cwcw
Change entire linecccc
Change to end of lineCC
Replace single characterr{char}r{char}
Substitute character (delete and insert)ss
Join line below to currentJJ
Toggle case of character~~
Undouu
RedoCtrl+RCtrl+R
Repeat last change..
Indent line>>>>
Outdent line<<<<
Auto-indent line====

Copy & Paste (Yank)

Yank (copy) lineyyyy
Yank wordywyw
Paste after cursorpp
Paste before cursorPP
Yank selection (Visual mode)yy
Delete (cut) selection (Visual mode)dd

Search & Replace

Search forward/pattern/pattern
Search backward?pattern?pattern
Next search matchnn
Previous search matchNN
Search word under cursor forward**
Search word under cursor backward##
Replace all in file:%s/old/new/g:%s/old/new/g
Replace all with confirmation:%s/old/new/gc:%s/old/new/gc

Files & Saving

Save file:w:w
Quit:q:q
Save and quit:wq:wq
Quit without saving:q!:q!
Save and quit (Normal mode)ZZZZ
Edit / open file:e filename:e filename

Windows & Tabs

Split window horizontallyCtrl+W SCtrl+W S
Split window verticallyCtrl+W VCtrl+W V
Switch between windowsCtrl+W WCtrl+W W
Close current windowCtrl+W QCtrl+W Q
Open new tab:tabnew:tabnew
Next tabgtgt
Previous tabgTgT

Marks & Macros

Set mark a at cursormama
Jump to line of mark a'a'a
Record macro into register aqaqa
Stop recording macroqq
Play macro in register a@a@a
Repeat last played macro@@@@

Put your top Vim shortcuts on real keys

The five Vim actions most worth binding to a physical macropad key:

EscEsc Return to Normal mode The most pressed key in Vim; a big dedicated Esc saves the pinky stretch.
:w:w Save file The save reflex fires constantly; one key for the whole :w Enter sequence.
:wq:wq Save and quit The canonical Vim exit as a single physical key ends every session cleanly.
.. Repeat last change The dot command is Vim's superpower for repetitive edits.
@a@a Play macro in register a Replaying a recorded macro on demand automates any repetitive edit.

I hand-build small-batch programmable macropads (QMK/VIA) in Barcelona. One press, any shortcut, any app.

See the macropads

Vim shortcut FAQs

How do I exit Vim?
Press Esc to make sure you are in Normal mode, then type :q and Enter to quit, :wq to save and quit, or :q! to quit and discard changes. ZZ in Normal mode also saves and quits.
Are Vim shortcuts the same on Windows and Mac?
Yes. Vim commands are plain keystrokes interpreted by the editor itself, not OS-level shortcuts, so hjkl, dd, :wq and everything else work identically on Windows, Mac, and Linux.
What do the letters hjkl do in Vim?
In Normal mode they move the cursor: h left, j down, k up, l right. They sit on the home row so you can navigate without reaching for the arrow keys.
How do I copy and paste in Vim?
Yank with y (yy copies a line), then paste with p after the cursor or P before it. Deleted text (dd, dw, x) also goes into the register and can be pasted with p.
How do I search and replace in Vim?
Type :%s/old/new/g and press Enter to replace every match in the file. Add c at the end (:%s/old/new/gc) to confirm each replacement, or use /pattern and n to just search.