CHAPTER 10 Editors
| Cursor Movement Commands: | ||
| (n) indicates a number, and is optional | ||
| (n)h | left (n) space(s) | |
| (n)j | down (n) space(s) | |
| (n)k | up (n) space(s) | |
| (n)l | right (n) space(s) | |
| (The arrow keys usually work also) | ||
| ^F | forward one screen | |
| ^B | back one screen | |
| ^D | down half screen | |
| ^U | up half screen | |
| (^ indicates control key; case does not matter) | ||
| H | beginning of top line of screen | |
| M | beginning of middle line of screen | |
| L | beginning of last line of screen | |
| G | beginning of last line of file | |
| (n)G | move to beginning of line (n) | |
| 0 | (zero) beginning of line | |
| $ | end of line | |
| (n)w | forward (n) word(s) | |
| (n)b | back (n) word(s) | |
| e | end of word | |
| Inserting Text: | ||
| i | insert text before the cursor | |
| a | append text after the cursor (does not overwrite other text) | |
| I | insert text at the beginning of the line | |
| A | append text to the end of the line | |
| r | replace the character under the cursor with the next character typed | |
| R | Overwrite characters until the end of the line (or until escape is pressed to change command) | |
| o | (alpha o) open new line after the current line to type text | |
| O | (alpha O) open new line before the current line to type text | |
| Deleting Text: | ||
| dd | deletes current line | |
| (n)dd | deletes (n) line(s) | |
| (n)dw | deletes (n) word(s) | |
| D | deletes from cursor to end of line | |
| x | deletes current character | |
| (n)x | deletes (n) character(s) | |
| X | deletes previous character | |
| Change Commands: | ||
| (n)cc | changes (n) characters on line(s) until end of the line (or until escape is pressed) | |
| cw | changes characters of word until end of the word (or until escape is pressed) | |
| (n)cw | changes characters of the next (n) words | |
| c$ | changes text to the end of the line | |
| ct(x) | changes text to the letter (x) | |
| C | changes remaining text on the current line (until stopped by escape key) | |
| ~ | changes the case of the current character | |
| J | joins the current line and the next line | |
| u | undo the last command just done on this line | |
| . | repeats last change | |
| s | substitutes text for current character | |
| S | substitutes text for current line | |
| :s | substitutes new word(s) for old :<line nos effected> s/old/new/g | |
| & | repeats last substitution (:s) command. | |
| (n)yy | yanks (n) lines to buffer | |
| y(n)w | yanks (n) words to buffer | |
| p | puts yanked or deleted text after cursor | |
| P | puts yanked or deleted text before cursor | |
| File Manipulation: | ||
| :w (file) | writes changes to file (default is current file) | |
| :wq | writes changes to current file and quits edit session | |
| :w! (file) | overwrites file (default is current file) | |
| :q | quits edit session w/no changes made | |
| :q! | quits edit session and discards changes | |
| :n | edits next file in argument list | |
| :f (name) | changes name of current file to (name) | |
| :r (file) | reads contents of file into current edit at the current cursor position (insert a file) | |
| :!(command) | shell escape | |
| :r!(command) | inserts result of shell command at cursor position | |
| ZZ | write changes to current file and exit | |