At One Place

Vim keyboard shortcuts

Vim keyboard shortcuts
89 shortcuts
Windows, macOS and Linux

A modal text editor: the same key does different things in Normal, Insert, Visual and Command-line mode, and everything below assumes Normal mode unless the group says otherwise — press Esc to get back there. Operators combine with motions and text objects, so d with 2w deletes two words and ci" changes what is inside the quotes; the tables list the pieces rather than every combination.

Modes

Shortcut What it does
Esc Return to Normal mode — Ctrl + [ does the same and is easier to reach
i Insert before the cursor
I Insert at the first non-blank character
a Append after the cursor
A Append at the end of the line
o Open a new line below and insert
O Open a new line above and insert
v Start characterwise Visual mode
V Start linewise Visual mode
Ctrl + V Start blockwise Visual mode

Cursor motion

Shortcut What it does
h j k l Move left, down, up and right
w Jump to the start of the next word
b Jump back to the start of the previous word
e Jump to the end of the current word
0 Move to the first column
^ Move to the first non-blank character
$ Move to the end of the line
gg Go to the first line
G Go to the last line
{count}G Go to a line by number
f{char} F{char} Jump onto the next or previous occurrence of a character
{ } Move back or forward a paragraph
% Jump to the matching bracket
H M L Jump to the top, middle or bottom of the screen
Ctrl + D Ctrl + U Scroll down or up half a screen
Ctrl + F Ctrl + B Page forward or back
Ctrl + O Ctrl + I Jump back or forward in the jump list

Editing

Shortcut What it does
x Delete the character under the cursor
dd Delete the current line
D Delete to the end of the line
cc Change the whole line
C Change to the end of the line
r{char} Replace one character in place
J Join the next line onto this one
u Undo the last change
Ctrl + R Redo
. Repeat the last change
>> << Indent or unindent the line one shiftwidth
gU{motion} gu{motion} Uppercase or lowercase over a motion
Ctrl + A Ctrl + X Increment or decrement the number under the cursor

Yank, registers and macros

Shortcut What it does
yy Yank the current line
y{motion} Yank over a motion
Y Yank the current line — Neovim remaps Y to yank to the end of the line
p Put after the cursor
P Put before the cursor
"+y Yank to the system clipboard — Needs a Vim built with +clipboard
"+p Put from the system clipboard
"0p Put the most recent yank — Register 0 survives deletes, so use it after a d clobbered the unnamed register
"{a-z}y Yank into a named register
q{a-z} Start recording a macro into a register
q Stop recording
@{a-z} Play back a macro
@@ Replay the last macro
m{a-z} Set a mark at the cursor
`{a-z} Jump to a mark
`` Jump back to where you were before the last jump

Search and replace

Shortcut What it does
/pattern Search forward
?pattern Search backward
n Go to the next match
N Go to the previous match
* Search forward for the word under the cursor
# Search backward for the word under the cursor
:noh Clear the search highlighting
:%s/old/new/gc Replace every match in the file, confirming each

Text objects

Shortcut What it does
iw Select the word under the cursor
aw Select the word plus its trailing whitespace
i" Select inside the double quotes
a" Select the quoted string including the quotes
i( Select inside the parentheses — ib is a synonym
a{ Select the braced block including the braces — aB is a synonym
it Select inside the surrounding tag
at Select the tag block including the tags

Insert mode

Shortcut What it does
Ctrl + N Complete with the next matching word
Ctrl + P Complete with the previous matching word
Ctrl + X then Ctrl + F Complete a filename
Ctrl + W Delete the word before the cursor
Ctrl + R then {reg} Insert the contents of a register
Ctrl + O Run one Normal mode command and come straight back

Files, windows and tabs

Shortcut What it does
:w Write the file
:q Close the window
:wq Write and close — :x is the same but only writes if the file changed
:q! Close and discard changes
ZZ Write and quit
ZQ Quit without writing
Ctrl + W then S Split the window horizontally
Ctrl + W then V Split the window vertically
Ctrl + W then W Cycle to the next window
Ctrl + W then H/J/K/L Move to the window in that direction
gt gT Go to the next or previous tab page

Common questions

How many keyboard shortcuts does Vim have?
This page lists 89 shortcuts across 8 groups, covering the ones people actually use day to day rather than every binding the application defines.
Are Vim shortcuts the same on Mac and Windows?
Mostly. The usual difference is that Ctrl on Windows becomes ⌘ on macOS, which is why the shortcuts here are written as "Ctrl/⌘". Where a binding genuinely differs beyond that swap, it is spelled out separately.

Related pages

Sources

  1. Official vendor product documentation — At One Place

How these figures are compiled and checked