A compact reference for the Vim commands you can use directly in this browser editor. Keep it open in a second tab while you practice, and pair it with the practical guide if a command needs more explanation.
Switching modes
| Keys | What it does |
|---|
i | Insert before the cursor |
a | Insert (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 Visual (selection) mode |
: | Start a Command-line command |
Esc | Return to Normal mode |
Moving the cursor
| Keys | What it does |
|---|
h / l | Move left / right one character |
j / k | Move down / up one line |
w / b | Jump forward / back by word |
0 | Go to the start of the line |
$ | Go to the end of the line |
{ / } | Jump to the previous / next blank line (paragraph) |
gg | Go to the first line of the file |
G | Go to the last line of the file |
Ctrl-f / Ctrl-b | Scroll a full page down / up |
Ctrl-d / Ctrl-u | Scroll a half page down / up |
Editing text
| Keys | What it does |
|---|
x | Delete the character under the cursor |
dd | Delete (cut) the current line |
>> / << | Indent / unindent the current line |
>j / 3>> | Indent with a motion or a line count |
~ | Toggle case of the character under the cursor |
guiw / gUiw | Lowercase / uppercase a word (motion or text object) |
g~w | Toggle case over a motion |
J / gJ | Join the next line (with / without a space) |
Ctrl-a / Ctrl-x | Increment / decrement the number under the cursor |
i text Esc | Insert text, then leave Insert mode |
Backspace | Delete back one character (Insert mode) |
Enter | Insert a new line (Insert mode) |
Visual mode
| Keys | What it does |
|---|
v / V / Ctrl-v | Start characterwise / linewise / block selection |
u / U / ~ | Lowercase / uppercase / toggle case of the selection |
r{char} | Replace every selected character |
J | Join the selected lines |
p | Replace the selection with the register |
> / < | Indent / unindent the selection |
o | Jump to the other end of the selection |
Copy, paste and registers
| Keys | What it does |
|---|
yy | Yank (copy) the current line into the register |
p / P | Paste the register after / before the cursor |
"ayy / "ap | Yank into / paste from named register a |
"0p | Paste the last yank (survives later deletes) |
"1p ... "9p | Paste from the numbered delete ring |
"_dd | Delete into the black hole (keep the register) |
"+p | Paste from the computer (system) clipboard |
Ctrl/Cmd + V | Paste the clipboard while in Insert mode |
Macros and reselect
| Keys | What it does |
|---|
qa ... q | Record keystrokes into register a |
@a | Play back the macro in register a |
@@ | Repeat the last played macro |
3@a | Play a macro a set number of times |
gv | Reselect the last Visual selection |
. | Repeat the last change |
Files and commands
| Keys | What it does |
|---|
:w | Write (save) the current file |
:wq | Write (save) the file, same as :w here |
:q | No-op in the browser (use :w to save) |
Up / Down | Browse command/search history at the : or / prompt |
How to read these commands
Most commands are typed in Normal mode—the mode you return to whenever you press Esc. Commands that start with a colon, like :w, are typed in Command mode and finished with Enter. If a key seems to type a letter instead of running a command, you are probably still in Insert mode: press Esc and try again.
Common Vim tasks, step by step
See all documents for the full list of guides, tutorials, and references.
Practice these in the editor