| 1. Invoking and exiting vi | 6. Searching
|
| $ vi file | invoke vi | /string | find next string
|
| $ view file | opens file in read-only mode | ?string | reverse search
|
| :wq | write and quit | n | repeat last / or ?
|
| :w | write | N | repeat last / or ? backwards
|
| :w file | write to file
|
| :w! file | overwrite existing file | 7. Change Text
|
| :q | quit | rc | replace char with c
|
| :q! | unconditional quit | nsstring<ESC> | substitute n chars with string
|
| cctext<ESC> | change line with text
|
| 2. Display Text | ncctext<ESC> | change n lines
|
| <CtrL/d> | scroll down | cwtext<ESC> | change word
|
| <CtrL/u> | scroll up | c$text<ESC> | change to end of line
|
| <CtrL/f> | page forward | nJ | join n lines
|
| <CtrL/b> | page backward | r<RET> | split line
|
| :1,$s/string/newstring/g | substitution
|
| 3. Cursor Movement | :%s/string/newstring/g
|
| <RIGHT> | <SP> | l | next char
|
| <LEFT> | <BS> | h | previous char | 8. Copying Text
|
| <DOWN> | j | char below | yy | yank entire line
|
| <UP> | k | char above | nyy | yank n lines from current line
|
| <RET> | beginning of next line | yw | yank word
|
| - | beginning of previous line | y$ | yank to end of line
|
| G | GOTO last line | p | put after char (line)
|
| :n | nG | GOTO line n | P | put before char (line)
|
| $ | end of line
|
| ^ | beginning of line | 9. Move Text
|
| w | nw | W | nW | forward beginning of word | use delete instead of yank
|
| e | ne | E | nE | end of word
|
| b | nb | B | nB | back beginning of word | 10. Miscellaneous
|
| xp | transpose 2 characters
|
| 4. Text Creation | :r file | read file into buffer
|
| atext<ESC> | append after cursor | :!spell % | run shell command on current file
|
| itext<ESC> | insert before cursor | <CtrL/l> | redraw screen
|
| otext<ESC> | open line below | $ vi -r file | recovery
|
| Otext<ESC> | open line above
|
| 11. Setting Options
|
| 5. Delete Text | :set number | number lines
|
| x | delete char | :set nonumber | turn off numbers
|
| nx | delete n chars | :set list | display tabs and end of lines
|
| rc | replace character | :set nolist | turn off list
|
| dd | delete current line | :set showmode | indicate input mode
|
| ndd | delete n lines | :set noshowmode | turn off showmode
|
| dw | delete word | :set wm=10 | define automatic right margin
|
| d$ | delete to end of line | :set wm=0 | turn off wm
|
| u | undo last editing command
|