NAME
     vi - visual editor

SYNOPSIS
     vi [file]

DESCRIPTION
     Vi is a small editor in the manner of Bill Joy's, which is to say a modal
     one.  In normal mode the letter keys are commands that move and change
     text; in insert mode what you type goes into the file.  i enters insert
     mode and escape leaves it.  The bottom line shows the filename, position,
     and -- INSERT -- when that is where you are.

     What follows is the whole of it.  This is a subset: enough vi to edit a
     config file without relearning your fingers, not enough to surprise you
     with an operator you were counting on.  In particular there are no counts
     -- 5j moves down one line and then types j, which is to say nothing.
     There are no operators other than dd and yy, no marks, no registers, and
     no e.  Undo remembers exactly one change.

MOVING
     h j k l
          Left, down, up, right.  The arrow keys do the same.

     w    Forward to the start of the next word, and on to the next line at
          the end of this one.

     b    Back to the start of the previous word.

     0 $  Start and end of the line.  home and end do the same.

     gg G First and last line of the file.

     ctrl-f ctrl-b
          Forward and back a screenful.  pgdn and pgup do the same.

     /pattern
          Search forward for pattern, wrapping at the end of the file.  It is
          matched as plain text, not a regular expression.

     n N  Repeat the search forward or backward.

CHANGING
     i a  Insert before or after the cursor.

     I A  Insert at the start or end of the line.

     o O  Open a line below or above and insert there.

     x    Delete the character under the cursor.  The delete key does the
          same.

     dd   Delete the line, holding it for p and P.

     yy   Yank the line without deleting it.

     p P  Put the held line below or above the cursor.  It is always put as a
          whole line; there is no character-wise yank.

     J    Join the next line onto this one, with a space between.

     u    Undo.  One change is remembered, and only from dd, x, J, o and O.
          Typing over text is not undoable.

INSERT MODE
     escape
          Return to normal mode.

     enter
          Split the line at the cursor.

     backspace
          Delete the character before the cursor, joining lines at the start
          of one.

     arrow keys
          Move without leaving insert mode.

EX COMMANDS
     : puts a colon on the bottom line and reads a command there.  escape
     abandons it.

     :w   Write the file.

     :q   Quit.  With unsaved changes this refuses and says so.

     :q!  Quit and discard the changes.

     :wq

     :x   Write and quit.

     :N   Go to line N.

     Nothing else is understood; anything else prints Not an editor command.
     There is no :s, no :g, and no :e.  For those, sam(1) is the better tool.

OTHER KEYS
     ZZ   Write and quit, as :wq.

     ctrl-z
          Suspend and return to the shell.  fg resumes with the buffer and
          cursor as you left them.

EXAMPLES
     Edit a file and save it:

          vi /n/local/rc/profile

     Then, having found the line:

          /aether
          A

FILES
     /env/editor
          Set this to vi to have gopher(1) and the rest use it rather than
          se(1).

SEE ALSO
     se(1), sam(1), ed(1)

NOTES
     The buffer holds at most 4096 lines of at most 256 characters, in PSRAM.
     Longer lines are split when the file is read.

BUGS
     Vi cannot create a file.  It will happily edit a name that does not
     exist, and then fail to write it with Write error.  Make the file first --
     touch or a write from se(1) -- or edit it in something else.

     Started with no filename at all, :w has nowhere to write and says No file
     name.  There is no way to give it one from inside the editor.

FRST Computer                                                            VI(1)
