Vim Scoops / Lessons
Learn Vim, one command at a time
Each lesson answers one question, shows you the keys, then lets you try them in a tiny level. Pick the one you came for, or play the whole game from the start.
Want it all on one page? The Vim cheat sheet has every command, and there are free wallpapers for your desktop.
The basics
- How to exit VimPress Esc, type
:qand press Enter. - How to save a file in VimPress Esc, type
:wand press Enter.
Moving
- How to move around in VimIn Normal mode, h moves left, j down, k up and l right.
- How to go to the start or end of a line in VimPress 0 to jump to the start of the line and $ to jump to the end.
- How to move word by word in VimPress w to jump to the start of the next word, b to go back a word and e to jump to the end of a word.
- How to go to a line number in VimType
:42and press Enter to jump to line 42. - How to jump to a character in VimPress f then a character to jump to the next one on the line, so
f(lands on the next bracket.
Editing
- How to type text in Vim (insert mode)Press i to start typing before the cursor and Esc when you're done.
- How to delete a line in VimPress dd in Normal mode to delete the line the cursor is on.
- How to delete a word in VimPut the cursor on the word and press
dawto delete it and the space after it. - How to copy and paste in VimPress yy to copy the current line, then p to paste it below the cursor or P to paste above.
- How to undo and redo in VimPress u in Normal mode to undo your last change, and Ctrl+r to redo it.
- How to repeat the last change in VimPress . to repeat your last change at the cursor.
- How to change text inside quotes in VimPress
ci"to delete everything inside the quotes and start typing.
Visual mode
- How to select text in VimPress v to start selecting, move the cursor to stretch the selection, then press d to delete, y to copy or c to change it.
- How to select a column in Vim (visual block mode)Press Ctrl+v to start a block selection, then move down and across to cover a column.
- How to select all in VimPress
ggto go to the top, V to select the line, then G to stretch the selection to the bottom.
Search
- How to search in VimPress /, type what you're looking for and press Enter.
- How to find and replace in VimType
:%s/old/new/gand press Enter to replace everyoldwithnewacross the file.
Macros
Errors
- E37: No write since last changeE37 means the file has changes you haven't saved, so Vim won't quit.
- E492: Not an editor commandE492 means Vim didn't recognise the command you typed after :.
- E486: Pattern not foundE486 means your search or
:scommand found no match in the file. - E325: ATTENTION, found a swap fileE325 means Vim found a swap file for this file: either another Vim has it open, or an earlier session crashed.
- E45: 'readonly' option is setE45 means Vim opened the file read-only, so
:wrefuses.
Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.
Play the full game