Vim keyboard shortcuts

Vim is a language of motions, operators, and modes rather than a list of isolated hotkeys. This reference covers the normal, insert, visual, search, window, and command-line paths that make the official quick reference useful at the keyboard.

Windows, macOS, Linux · 69 shortcuts

Modes and movement

Start in normal mode, move by character or text object, and use the same motions as building blocks for operators.

ActionWindowsmacOSLinux
Insert before the cursoriii
Insert after the cursoraaa
Insert at the first non-blank characterIII
Append at the end of the lineAAA
Open a new line belowooo
Open a new line aboveOOO
Return to normal modeEscEscEsc
Move lefthhh
Move downjjj
Move upkkk
Move rightlll
Move to the first non-blank character0 moves to column one.^^^
Move to the end of the line$$$
Move to the next word startwww
Move to the previous word startbbb
Move to the next word endeee
Move to the start of the filegggggg
Move to the end of the fileGGG
Jump to the matching bracket or parenthesis%%%
Jump to the older cursor positionCtrl+i jumps forward through the jump list.CtrloCtrloCtrlo
Find a character forward on the lineType f then the character. t lands just before it; F and T search backward.fff

Editing and registers

Use operators with motions, change or delete text, work with registers, and repeat edits in normal mode.

ActionWindowsmacOSLinux
Delete the current linedddddd
Delete the character under the cursorX deletes the character before the cursor.xxx
Delete from the cursor to line endDDD
Change the word under the cursorThe ci text-object pattern also works with parentheses, quotes, and other objects.ciwciwciw
Change the whole linecccccc
Change from the cursor to line endCCC
Replace one characterType r then the replacement character.rrr
Join the current line with the nextJJJ
Copy (yank) the current lineyyyyyy
Copy text covered by a motionPress y then a motion, such as yw or y$.yyy
Paste after the cursorP pastes before the cursor.ppp
Undo the last changeuuu
Redo an undone changeCtrlrCtrlrCtrlr
Repeat the last change...
Toggle the case of the character~~~
Start character-wise visual modevvv
Start line-wise visual modeVVV
Start block-wise visual modeCtrlvCtrlvCtrlv
Indent the selected or motion range right>>>
Indent the selected or motion range left<<<

Search, replace, and folds

Search forward or backward, move through matches, replace text, and reveal or hide folded code.

ActionWindowsmacOSLinux
Search forwardType a pattern and press Enter. ? searches backward.///
Go to the next search matchN goes to the previous match.nnn
Search forward for the word under the cursor# searches backward.***
Clear search highlighting:nohlsearch:nohlsearch:nohlsearch
Replace text on the current lineFor example, :s/old/new/g replaces every match on the line.:s:s:s
Replace text across the fileFor example, :%s/old/new/g replaces every match in the file.:%s:%s:%s
Open or close the fold under the cursorzazaza
Close the fold under the cursorzczczc
Open the fold under the cursorzozozo
Open all foldszRzRzR
Close all foldszMzMzM

Windows, files, and commands

The Ctrl+w prefix manages windows; command-line entries save, quit, edit, and move through files and buffers.

ActionWindowsmacOSLinux
Split the window horizontallyCtrlwsCtrlwsCtrlws
Split the window verticallyCtrlwvCtrlwvCtrlwv
Move to the next windowCtrlwwCtrlwwCtrlww
Move to the window on the leftCtrlwhCtrlwhCtrlwh
Move to the window belowCtrlwjCtrlwjCtrlwj
Move to the window aboveCtrlwkCtrlwkCtrlwk
Move to the window on the rightCtrlwlCtrlwlCtrlwl
Close the current windowCtrlwqCtrlwqCtrlwq
Equalize window sizesCtrlw=Ctrlw=Ctrlw=
Write the current file:w:w:w
Quit Vim:wq or :x writes and quits; :q! quits without saving.:q:q:q
Write and quit:wq:wq:wq
Quit without saving:q!:q!:q!
Edit a fileType :e followed by a path, then press Enter.:e:e:e
Edit the next buffer:bn:bn:bn
Edit the previous buffer:bp:bp:bp
Open the command-line prompt:::

Make a printable Vim sheet