Cheat sheet · Tools
Vim cheat sheet
Enough Vim to open, edit, search, save and leave any file without panic, on any server.
- Sections
- 5
- Items
- 24
- Area
- Tools
- Download
- PNG, PDF
Cheat sheet
Vim
Enough Vim to open, edit, search, save and leave any file without panic, on any server.
Modes
Esc- Normal mode: move and run commands
i / a- Insert before / after the cursor
o / O- Insert a new line below / above
v / V- Select characters / whole lines
:- Command mode (save, quit, replace)
Move
h j k l- Left, down, up, right
w / b- Next word / previous word
0 / $- Start / end of the line
gg / G- Top / bottom of the file
Ctrl-d / Ctrl-u- Half a page down / up
:42- Go to line 42
Edit
x- Delete the character under the cursor
dd- Delete (cut) the line
yy / p- Copy the line / paste it below
cw- Change the word
u / Ctrl-r- Undo / redo
.- Repeat the last change
Search and replace
/text- Search forward (n next, N previous)
:%s/old/new/g- Replace every old with new in the file
:%s/old/new/gc- Same, asking for each one
Save and quit
:w- Save
:q- Quit
:wq or ZZ- Save and quit
:q!- Quit and throw away changes
Remember
- Stuck? Press Esc twice, then type :q! and Enter to leave without saving.
- Counts work with most commands: 3dd deletes three lines, 5j moves five lines down.
Learn it properly
A cheat sheet helps you remember. These lessons explain the ideas step by step, with examples.