This vim cheat sheet follows the official Vim help for motions and changes and lists the commands you will use every day. [1] [2] Vim has modes: you move and edit in Normal mode, type text in Insert mode and select in Visual mode. Press Esc to return to Normal mode before you try any of these commands.
How to use the vim cheat sheet
- Type in the search box to filter by any word in a name, a command or its note.
- Choose a topic to see one group instead of the whole list.
- Read the command in the right-hand column and its meaning on the left.
- Press Print for a clean copy of whatever is shown.
What is in each topic
The vim cheat sheet is split into 5 topics. The table shows how many entries each topic holds and which ones they are, so you can jump straight to the right group with the topic box.
| Topic | Entries | What it covers |
|---|---|---|
| Moving around | 11 | left, down, up, right; next word; previous word; end of word; start of line; end of line; first line; last line; matching bracket; find a character; next paragraph |
| Editing | 9 | delete a character; delete a line; delete a word; change a word; replace a character; join lines; switch case; indent a line; repeat the last change |
| Copy and paste | 4 | copy a line; paste after the cursor; paste before the cursor; delete then paste |
| Modes and saving | 7 | back to normal mode; insert before the cursor; insert after the cursor; visual mode; save; quit; save and quit |
| Search and replace | 6 | search forward; search backward; next and previous match; replace on a line; replace in the file; undo |
Moving around
The keys h, j, k and l move left, down, up and right. w moves to the start of the next word, b to the start of the previous word and e to the end of a word. 0 goes to the first character of the line and $ to the end. [1] gg goes to the first line and G to the last, and either takes a line number as a count. [1]
% jumps to the matching bracket, f followed by a character moves onto the next occurrence of that character on the line, and the curly brackets move backward and forward by paragraph. [1] Learning a handful of motions is worth more than holding down the arrow keys.
Editing, copying and pasting
x deletes the character under the cursor, dd deletes a whole line, and d followed by a motion deletes the text the motion covers. cw deletes a word and starts Insert mode, r replaces one character, J joins the current line with the next, and >> shifts a line one shiftwidth to the right. [2]
yy yanks (copies) a line, p puts the text after the cursor and P before it. The dot repeats the last change, which makes repeated edits quick. [2] Undo with u. The undo key and the commands for saving and searching are described in other parts of the help and are listed here from our own working.
Modes, saving and search
Press i to insert before the cursor, a to insert after it and v to start Visual mode. Esc returns to Normal mode. To save, type :w; to quit, :q; to save and quit, :wq; and to quit without saving, :q!.
Search forward with /text and backward with ?text, then press n for the next match. To replace, :s/old/new/ changes the first match on the current line and :%s/old/new/g changes every match in the file. Try a replacement on a copy of important files, because Vim applies it at once.
Who this page helps
Developers use a cheat sheet to look up a command they have not typed for a while, to learn the names of the options and to compare similar commands. Beginners can read down a topic to see what is possible, and experienced users can search for the one flag they forgot.
Tips for getting the most from the vim cheat sheet
- Learn a few motions first: w, b, 0, $ and gg, G cover most movement.
- Combine an operator with a motion, such as d followed by w, to build edits you have never memorised.
- Press Esc often. If a key seems to do nothing, you may be in the wrong mode.
Common mistakes
Most problems come from running a command in the wrong place or with the wrong target. Read a command before you press Enter, replace every placeholder with your own value, and try destructive commands on a test copy first. When a command behaves differently from the note, check the version you have installed and the official documentation.
Where the entries come from
Each command was checked against the documentation listed below this article. Where a command is standard but is not shown on the page we read, the article says it is our own working. Options and defaults change between releases, so run the help command for the version you have installed before you rely on a flag.
What this page does not do
It lists the commands most people need and does not try to cover every option. For the complete syntax, error messages and advanced features, open the official documentation linked in the sources, and keep it beside the cheat sheet while you learn.
Printing and checking
Filter by topic before you print if you only need one section, and the printed page will be shorter. The notes are short on purpose, so keep your textbook or the official documentation open for the full detail and for anything that changes between versions.
What next
Use this often? Add Vim Cheat Sh to your Home screen.
Frequently asked questions
What is in this vim cheat sheet?
Motions, editing commands, copy and paste, modes, saving and quitting, search and replace and undo.
How do I exit Vim?
Press Esc, then type :q and Enter to quit, :wq to save and quit, or :q! to quit without saving.
What does dd do?
It deletes the current line. With a count, such as 3dd, it deletes that many lines, and the deleted text can be pasted with p.
How do I repeat my last edit?
Press the dot key in Normal mode. It repeats the last change.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.