vi_reference.txt -- vi quick reference ======================================= ( two commands seperated by | are synonymous, numbers in commands are examples and may be replaced appropriately ) [ change modes ] | [ save, exit ] | ESC leave edit mode, enter command mode | | type one of the following commands to enter edit mode : | | a append new text, after cursor | :w write file i insert new text, before cursor | :w filename write file to filename o open line below cursor line, start editing | :q quit O open line at cursor position, start editing | :q! quit & discard changes | -----------------------------------------------------------+----------------------------------------------- | [ copy text ] | [ delete text ] | yy | Y copy line cursor is on | dd | D delete cursor line 13Y copy next 13 lines | 3dd delete next 3 lines p append line(s) after cursor line | x delete character under cursor | | -----------------------------------------------------------+----------------------------------------------- | [ find text ] | [ various ] | /foo find next string "foo" | 22G move to line 22 ?bar find previous string "bar" | u undo _last_ action n jump to next match of last find command | | | some hints : - vi(1) has a command mode and an edit mode. after starting it, you're in command mode and may type i to enter edit mode. you cannot issue commands in edit mode. press ESC to enter command mode again. - just press ESC multiple times if you did weird things and got lost (taken from the vi(1) manpage of OpenBSD 3.4)