man(1) Manual page archive


     VI(1)                                                       VI(1)

     NAME
          ex, edit, vi - text editor

     SYNOPSIS
          ex [ option ... ] file ...

          edit [ option ... ] file ...

          vi [ option ... ] file ...

     DESCRIPTION
          Ex is elaborated from ed(1). Vi is the display editing
          aspect of ex; edit is a simplified subset of ex. The editors
          work on several files simultaneously.  Vi gets the terminal
          type from environment variable TERM.

          The options are:

          -r file
               Recover the file after a crash in the editor.  If no
               file is specified, list all saved files.

          -l   Lisp indent mode; give special meaning to editor com-
               mands ()[]{}.

          -wn  Default window size is n lines.

          -x   Edit encrypted files; a key will be prompted for.

          -R   Read only; no files will be changed.

          +cmd Execute the specified ex command upon entering the edi-
               tor.

          The editors begin in `command mode'. An ESC character typed
          in command mode cancels the command.  The commands a A c C i
          I o O R s S enter input mode, where arbitrary text may be
          entered.  ESC or interrupt returns to command mode.  The
          commands : / ? !  take input from the last line of the
          screen, which is ended by a newline, or canceled by an
          interrupt.

          A number preceding commands z G | specifies a line.  A num-
          ber before almost any other command causes it to be
          repeated.

          In the following summary of vi commands ^ means the `con-
          trol' key.  Commands so marked work in input mode; others
          work in command mode.

     VI(1)                                                       VI(1)

          File manipulation
          :w       write back changes     :e!      reedit, discarding changes
          :w file  write file             :e +     file edit, starting at end
          :w! file overwrite file         :e + startingat line n
          :q       quit                   :sh      run shell, then return
          :q!      quit, discarding changes:! cmd   run shell command
          :e file  edit file              :n       edit next file argument
                                          : ex-cmd do editor command

         Positioning in file
         ^F       forward screen         n        repeat last \  or  ?
         ^B       backward screen        /pat/+_ n nth line after or before pat
         ^D       down half screen       (        beginning of sentence
         ^U       up half screen         )        end of sentence
         G        to specified line (end d{efault) beginning of paragraph
         / pat    next line matching pat }        end of paragraph
         ? pat    previous line matching %        find matching (){}

        Adjusting the screen
        ^L       clear and redraw       z.       ... at center
        ^R       retype, eliminate @ line/spat/z-  pat line at bottom
        z        redraw, current line atzwinndow  use n-line window
        z-       ... at bottom          ^E       scroll down one line
                                        ^Y       scroll up one line

       Marking and returning
       ``       move cursor to previousmcoxntext mark position with letter x
       ''       ... at first nonwhite in` x      move cursor to mark
                                       ' x      ... at first nonwhite

      Line positioning
      H        top line of screen     -        previous line, at first nonwhite
      L        bottom line            <newline>same as +
      M        middle line            j        next line, same column
      +        next line, at first nonwkhite    previous line, same column

     Character positioning
     ^        first nonwhite (not CTRLf)x      find x forward
     0        beginning of line      F x      find backward
     $        end of line            t x      upto x forward
     l        forward                T x      back upto x
     h        backward               ;        repeat last f F t
     ^L       ^H same as l h         ,        opposite of ;
     <space>  same as l        |        to specified column
                                     %        find matching (){}

     Words, sentences, paragraphs
     w        word forward
     b        word backward
     e        end of word
     )        next sentence
     (        previous sentence

VI(1)                                                       VI(1)