
| Movement Commands | |||
|---|---|---|---|
| Word/Line | Screen | ||
| h | go one space left | ctrl-d | go down half a screen |
| l | go one space right | ctrl-u | go up half a screen |
| j | go one line down | ctrl-f | go forward a screen |
| k | go one line up | ctrl-b | go back a screen |
| w | go to next word | H | go to top of screen |
| W    | go to next space | M | go to middle of screen |
| b | go to start of word | L | go to bottom of screen |
| B | go to previous space | G | go to end of text |
| e | go to end of word | xG | go to line x |
| ^ | beginning of line | mx | mark this line by x |
| $ | end of line | `x | go to line marked by x |
| Text Modification Commands | |||
|---|---|---|---|
| Delete | Change | ||
| dd | delete the current line | cc | change the current line |
| xdd | delete x lines | xcc | change x lines |
| dw | delete to end of word | cw | change to end of word |
| dW | delete to the next space | cW | change to next space |
| db | delete to beginning of word | cb | change to beginning of word |
| dB | delete to the previous space | cB | change to previous space |
| D | delete to end of line | C | change to end of line |
| x | delete character | s | Substitute text for character |
| X | delete character to left | S | Substitute for entire line |
| Search Commands | |
|---|---|
| /pattern | search forward through the text for pattern |
| ?pattern | search backward through the text for pattern |
| n | repeat the most recent search |
| Insert Commands | Miscellaneous Commands | ||
|---|---|---|---|
| i | insert mode | ctrl-g | show status line |
| a | append mode | ctrl-l | redraw screen |
| I | insert at beginning of line | J | join two lines together |
| A | append at end of line | . | repeat the last command |
| r | replace a single character | u | undo the last command |
| R    | overstrike mode | U | restore line to original |
| o | open a line below the cursor | ~ | change case of character |
| O | open a line above the cursor | xp | transpose two characters |
| Yank and Put Commands | |
|---|---|
| p | put the last deleted line(s) after the current line |
| P | put the last deleted line(s) before the current line |
| yy | yank the current line into the buffer |
| "xnyy | yank n lines into x buffer |
| "xp | put the contents of x buffer after current line |
| Saving, Quitting and Colon Commands | ||
|---|---|---|
| :! cmd | execute cmd | |
| :e file | edit file | |
| :n | next file; when editting multiple files | |
| :q | quit the editor (allowed only if no changes) | |
| :q! | quit the editor no matter what | |
| :r file | read the contents of file into editor | |
| :r! cmd | read output of cmd into text | |
| :w | write the contents of the editor to the original file | |
| :w file | write the contents of the editor to file | |
| :wq | write out the file and quit the editor | |
| ZZ | write out the file and quit the editor | |
