Appendix B. Editor cheat sheet

This summary is laid out as follows:

Table B-1. Layout of editor cheat sheets

RunningRecommended command line for starting it.
UsingReally basic howto. This is not even an attempt at a detailed howto.
ExitingHow to quit.
GotchasOddities to watch for.

B.1. vi

B.1.1. Running

% vi filename

B.1.2. Using

  • i to enter insert mode, then type text, press ESC to leave insert mode.

  • x to delete character below cursor.

  • dd to delete the current line

  • Cursor keys should move the cursor while not in insert mode.

  • If not, try hjkl, h = left, l = right, j = down, k = up.

  • /, then a string, then ENTER to search for text.

  • :w then ENTER to save.

B.1.3. Exiting

  • Press ESC if necessary to leave insert mode.

  • :q then ENTER to exit.

  • :q! ENTER to exit without saving.

  • :wq to exit with save.

B.1.4. Gotchas

vi has an insert mode and a command mode. Text entry only works in insert mode, and cursor motion only works in command mode. If you get confused about what mode you are in, pressing ESC twice is guaranteed to get you back to command mode (from where you press i to insert text, etc).

B.1.5. Help

:help ENTER might work. If not, then see the manpage.