Summary
Memorize keyboard shortcuts for the Vim editor. Most apply to vi also.Conventions used
The ^ means hold down the ctrl key. For example, ^w means hold down ctrl and press w. Also, pressing Enter is necessary after commands that begin with : but this is omitted for brevity.Movement
Getting around the screen...
| Key (memorize) | Description (memorize) |
|---|---|
| h | left |
| l | right |
| k | up |
| j | down |
| 0 | beginning of line |
| $ | end of line |
| w | forward 1 word |
Note that the arrow keys also work for moving around. Also, feel free to use the mouse to move around and select (won't work in a terminal window).
Editing
Once you've enter edit mode (usually via i or A) and insert some text, you'll usually want to press esc (or ^[ ) so you can again use the movement-related commands.
| Key (memorize) | Description (memorize) |
|---|---|
| i (then start typing) | insert text |
| esc (or ^[ ) | exit edit mode |
| A (then start typing) | insert text (starting at end of line) |
| a | insert text (after cursor) |
| cw (then start typing) | insert text (in place of a word) |
Saving and quitting, etc.
| Question (memorize) | Answer (memorize) |
|---|---|
| :w | save file |
| ZZ or :wq | exit (saving file) |
| :q! | exit (without saving file) |
| :e myfile.txt | open myfile.txt (in current dir) |
| :E | view current dir |
Misc
| Key (memorize) | Description (memorize) |
|---|---|
| u | undo |
| ^r | redo |
| . | repeat |
| ^[ | shortcut for escape |
| 3j | down 3 lines |
| 3G | go to line 3 |
| ^o | go back to previous locations |
Note that typing numbers before commands usually means "repeat the command this many times" (as in 3 j).
Searching
| Key (memorize) | Description (memorize) |
|---|---|
| / | search |
| ? | search (backward) |
| ^p (while searching) | do previous search |
| ^n (while searching) | do next search |
| ^f (while searching) | see previous searches |
| fa | go to next instance of a (on same line) |
| * | find next instance of word |
Incremental searching is a very cool feature. It means that the cursor will search forward as you type a search string (used with / search). Add "set incsearch" to your .vimrc file if incremental searching isn't enabled.
Add a section to this page!
- Click this button to contribute to this page (by adding a section here).♦
Feel free to experiment. Your edits won't immediately show up to everyone.



working...