Home Tools Blog About

Vim Cheat Sheet

Vim is a fast, keyboard-driven text editor found on almost every server. This cheat sheet lists the core keys for moving, editing, searching, and saving, grouped by task.

Modes

Key What it does
i / a Insert before or after the cursor
I / A Insert at the start or end of the line
o / O Open a new line below or above
Esc Return to normal mode
v / V Visual select by character or by line
Ctrl-v Visual block select
: Enter command-line mode

Move

Key What it does
h j k l Left, down, up, right
w / b Jump to the next or previous word
0 / ^ / $ Line start, first non-blank, line end
gg / G Top or bottom of the file
{number}G Go to a line number
Ctrl-d / Ctrl-u Half page down or up
{ / } Previous or next paragraph

Edit

Key What it does
x Delete the character under the cursor
dd / yy Delete (cut) or yank (copy) a line
p / P Paste after or before the cursor
cw Change to the end of the word
r<char> Replace a single character
u / Ctrl-r Undo or redo
. Repeat the last change
>> / << Indent or outdent the line

Search and replace

Key What it does
/text Search forward (use ?text to search back)
n / N Next or previous match
* Search for the word under the cursor
:%s/old/new/g Replace every match in the file
:%s/old/new/gc Replace every match, asking for confirmation

Files and windows

Key What it does
:w Save (write) the file
:q Quit (use :q! to discard changes)
:wq or ZZ Save and quit
:e <file> Open a file
:sp / :vsp Split the window horizontally or vertically
Ctrl-w then h j k l Move between split windows

Frequently Asked Questions

How do I quit Vim?

Press Esc, then type :q and Enter. Use :q! to quit without saving, or :wq to save and quit.

What is the difference between normal and insert mode?

Normal mode is for navigation and commands. Insert mode is for typing text. Press i to start inserting and Esc to return to normal mode.

How do I copy and paste in Vim?

Yank a line with yy, or select in visual mode and press y, then paste with p. This uses the registers in Vim rather than the system clipboard unless configured.

How do I search and replace in Vim?

Use :%s/old/new/g to replace every match in the file. Add a c at the end to confirm each change one by one.

See our free developer tools for text and code work.

ATV

Written by Nick (ATV Team)

We build and maintain the 600+ free, client-side tools on this site, and every guide is written against the tools themselves: each figure is computed and checked before it is published, and every linked tool is tested in the browser. More about how we work on the about page, and the full library of guides lives on the blog.