Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

edit(1)

ex(1)

vi(1)

curses(3)

terminfo(4)



  vi(1)                               CLIX                               vi(1)



  NAME

    vi, view, vedit - Screen-oriented (visual) display editor based on ex

  SYNOPSIS

    vi [-ClLRVx] [-t tag] [-r file] [-wn] [-c command] file ...

    view [-ClLRVx] [-t tag] [-r file] [-wn] [-c command] file ...

    vedit [-ClLRVx] [-t tag] [-r file] [-wn] [-c command] file ...

  FLAGS

    -c command   Allows the user to begin editing a file by executing a
                 specified editor command (usually a search or positioning
                 command) from the command line.

    -C           Invokes the encryption flag and operates similarly to the -x
                 flag, except that vi simulates the C command of ex, in which
                 all text is assumed to be encrypted.

    -l           Turns on Lisp mode.  The Lisp mode is used to notify the user
                 when mismatched parentheses, braces, or brackets have been
                 entered in text displayed in the vi editor.

    -L           Lists the name of all files saved as the result of an editor
                 or system crash.

    -r file      Edits the named file after an editor or system crash,
                 recovering the version of the file that was in the buffer
                 when the crash occurred.

    -R           Invokes the readonly mode.  The -R flag is used to prevent
                 accidental overwriting of the file.

    -t tag       Edits the file containing the tag and positions the editor at
                 the tag definition.

    -V           Turns on verbose mode.  The verbose mode echoes the exrc file
                 which contains startup keyboard and terminal information for
                 vi and other editors.  Refer to ex(1) for more information on
                 the verbose mode.

    -wn          Sets the default window size to n.  This flag is useful when
                 using the editor over a slow speed line.

    -x           Sets the encryption flag, which, when used with the vi
                 editor, simulates the X command for ex and prompts the user
                 for a key.  This key is used to encrypt and decrypt text
                 using the algorithm of the crypt() function.  The X command



  2/94 - Intergraph Corporation                                              1






  vi(1)                               CLIX                               vi(1)



                 makes an educated guess to determine whether text is
                 encrypted or not.  The temporary buffer file is encrypted
                 also, using a transformed version of the key typed in for the
                 -x flag.  See crypt(3) and also the CAUTIONS section of this
                 manual page.

  DESCRIPTION

    The vi (visual) editor is a display-oriented text editor based on the
    underlying ex line editor.  Both vi and ex were developed by the
    University of California, Berkeley California, Computer Science Division,
    Department of Electrical Engineering and Computer Science.

    The file parameter specifies one or more files to be edited.

    The view invocation is the same as vi except that the readonly flag (-R)
    is set.

    The vedit invocation is intended for beginners.  It is the same as vi
    except that the report flag is set to 1, the showmode and novice flags are
    set, and magic is turned off.  These defaults make it easier to learn how
    to use vi.

    It is possible to use the command mode of ex from within vi and vice-
    versa.  The visual commands are described here.  Information on setting
    options (such as automatic line numbering) and all ex line editor commands
    are described in ex(1).

    When using the vi editor, changes you make to the file are reflected in
    what you see on your terminal screen.  The position of the cursor on the
    screen indicates the position within the file.

  vi Modes

    The vi editor includes the following modes:

    Command   This is the default mode of the vi editor.  Other modes return
              to the command mode upon completion.  Pressing the <Esc>
              (Escape) key cancels a partially input command.

    Input     The input mode can be started by typing any one of the following
              flags after the vi editor has been invoked:  -a, -A, -i, -I, -o,
              -O, -c, -C, -s, -S, -R.

              After inputing one of these characters, arbitrary text can then
              be entered.  The input mode is normally terminated by pressing
              <Esc> or, abnormally, with an interrupt.

    Last line The last line mode reads the input for the last line of the
              screen.  To position the cursor on the last line, the user must
              press the a colon (:), slash (/), question mark (?), or



  2                                              Intergraph Corporation - 2/94






  vi(1)                               CLIX                               vi(1)



              exclamation point (!).  This mode can be terminated by pressing
              <Return>.  The termination process can be cancelled by pressing
              <Break> (the interrupt key).


  Text Editing Commands

    Following is a list of commands and associated keystrokes for use in the
    vi editor.  In the descriptions, <CR> represents pressing <Return>, <Esc>
    represents pressing <Esc>, and a circumflex (^) represents pressing
    <Ctrl>.

  Sample Commands

    <- ↓ ↑ ->     Arrow keys move the cursor.
    h  j  k  l    Same as arrow keys.
    itext<Esc>    Inserts text.
    cwword<Esc>   Changes a word to word.
    eas<Esc>      Pluralizes a word (moves to end of word;
                  appends s; escapes from input state).
    x             Deletes a character.
    dw            Deletes a word.
    dd            Deletes a line.
    3dd           Deletes 3 lines.
    u             Undoes previous change.
    ZZ            Exits vi, saving changes.
    :q!<CR>       Quits, discarding changes.
    /text<CR>     Searches for text.
    ^U ^D         Scrolls up or down.
    :cmd<CR>      Runs any ex or ed command.

  Counts Before vi Commands

    Numbers may be typed as a prefix to some commands.  They are interpreted
    in one of the following ways.
    Line/column number   z  G  |
    Scroll amount        ^D  ^U
    Repeat effect        most of the rest

  Interrupting and Canceling

     <Esc>        Ends insert or incomplete command.
     DEL          Interrupts (delete or rubout).

  File Manipulation

     ZZ                Writes and exits if file modified; otherwise, exits.
     :w<CR>            Writes back changes.
     :w!<CR>           Forces write (if permission originally not valid).





  2/94 - Intergraph Corporation                                              3






  vi(1)                               CLIX                               vi(1)



     :q<CR>            Quits.
     :q!<CR>           Quits, discards changes.
     :e name<CR>       Edits file name.
     :e!<CR>           Reedits, discards changes.
     :e + name<CR>     Edits, starting at end.
     :e +n<CR>         Edits starting at line n.
     :e #<CR>          Edits alternate file.
     :e! #<CR>         Edits alternate file, discards changes.
     :w name<CR>       Writes file name.
     :w! name<CR>      Overwrites file name.
     :sh<CR>           Runs shell, then returns.
     :!cmd<CR>         Runs cmd, then returns.
     :n<CR>            Edits next file in argument list.
     :n args<CR>       Specifies new argument list.
     ^G                Shows current file and line.
     :ta tag<CR>       Positions cursor to tag.

    In general, any ex or ed command (such as substitute or global) may be
    entered, preceded by a colon and followed by pressing <Return>.

  Positioning Within a File

     ^F           Scrolls forward a screen.
     ^B           Scrolls back a screen.
     ^D           Scrolls down half screen.
     ^U           Scrolls up half screenn.
     nG           Moves to beginning of specified line
                  (end default), where n is a line
                  number.
     /pat         Moves to next line matching pat.
     ?pat         Moves to previous line matching pat.
     n            Repeats last / or ? command.
     N            Reverses last / or ? command.
     /pat/+n      Moves to nth line after pat.
     ?pat?-n      Moves to nth line before pat.
     ]]           Next section/function.
     [[           Previous section/function.
     (            Moves to beginning of sentence.
     )            Moves to end of sentence.
     {            Moves to beginning of paragraph.
     }            Moves to end of paragraph.
     %            Finds matching (, ), {, or }.

  Adjusting the Screen

     ^L              Clears and redraws window.
     ^R              Clears and redraws window if ^L is right arrow (->) key.
     z<CR>           Redraws screen with current line at top of window.
     z-<CR>          Redraws screen with current line at bottom of window.





  4                                              Intergraph Corporation - 2/94






  vi(1)                               CLIX                               vi(1)



     z.<CR>          Redraws screen with current line at center of window.
     /pat/z-<CR>     Moves pat line to bottom of window.
     zn.<CR>         Uses n-line window.
     ^E              Scrolls window down 1 line.
     ^Y              Scrolls window up 1 line.

  Marking and Returning

     ``        Moves cursor to previous context.
     ''        Moves cursor to first nonwhite space in line.
     mx        Marks current position with the ASCII lowercase letter x.
     `x        Moves cursor to mark x.
     'x        Moves cursor to first nonwhite space in line marked by x.

  Line Positioning

     H          Moves to top line on screen.
     L          Moves to last line on screen.
     M          Moves to middle line on screen.
     +          Moves to next line, at first nonwhite.
     -          Moves to previous line, at first nonwhite.
     <CR>       Returns, same as +.
     ↓ or j     moves to next line, same column.
     ↑ or k     moves to previous line, same column.

  Character Positioning

     ^           Moves to first nonwhite-space character.
     0           Moves to beginning of line.
     $           Moves end of line.
     h or ->     Moves forward.
     l or <-     Moves backward.
     ^H          Same as <- (or <Back Space>).
     space       Same as -> (or space bar).
     fx          Finds next x.
     Fx          Finds previous x.
     tx          Moves to character prior to next x.
     Tx          Moves to character following previous x.
     ;           Repeats last f, F, t, or T.
     ,           Repeats inverse of last f, F, t, or T.
     n|          Moves to column n.
     %           Finds matching (, {, ), or }.

  Words, Sentences, and Paragraphs

     w         Moves forward a word.
     b         Moves back a word.
     e         Moves to end of word.
     )         Moves to next sentence.





  2/94 - Intergraph Corporation                                              5






  vi(1)                               CLIX                               vi(1)



     }         Moves to next paragraph.
     (         Moves back a sentence.
     {         Moves back a paragraph.
     W         Moves forward a blank-delimited word.
     B         Moves to back a blank-delimited word.
     E         Moves to end of a blank-delimited word.

  Corrections During Insert

     ^H        Erases last character (backspace).
     ^W        Erases last word.
     erase     Erase character, same as ^H (backspace).
     kill      Kill character, erases this line of input.
     \         Quotes your erase and kill characters.
     <Esc>     Ends insertion, returns to command mode.
     DEL       Interrupts, terminates insert mode.
     ^D        Backtabs one character; resets left margin of autoindent.
    ^^D        Circumflex (^) followed by <Ctrl-D>;
               backtabs to beginning of line, does
               not reset left margin of autoindent.
    0^D       Backtabs to beginning of line; resets left margin of autoindent.
    ^V        Quotes nonprintable character.

  Insert and Replace

     a              Appends after cursor.
     A              Appends at end of line.
     i              Inserts before cursor.
     I              Inserts before first nonblank.
     o              Opens line below.
     O              Opens line above.
     rx             Replaces single char with x.
     Rtext<Esc>     Replaces characters.

  Operators

    Operators are followed by a cursor motion, and affect all text that would
    have been moved over.  For example, since w moves over a word, dw deletes
    the word that would be moved over.  Double the operator, for example, dd
    to affect whole lines.
     d       Deletes.
     c       Changes.
     y       Yanks lines to buffer.
     <       Left shifts.
     >       Right shifts.
     !       Filters through command.

  Miscellaneous Operations

     C       Changes rest of line (c$).
     D       Deletes rest of line (d$).



  6                                              Intergraph Corporation - 2/94






  vi(1)                               CLIX                               vi(1)



     s       Substitutes chars (cl).
     S       Substitutes lines (cc).
     J       Joins lines.
     x       Deletes characters (dl).
     X       Deletes characters before cursor (dh).
     Y       Yanks lines (yy).

  Yank and Put

    Put inserts the text most recently deleted or yanked; however, if a buffer
    is named (using the ASCII lowercase letters a - z), the text in that
    buffer is ``put'' instead.
     3yy     Yanks 3 lines.
     3yl     Yanks 3 characters.
     p       Puts back text after cursor.
     P       Puts back text before cursor.
     "xp     Puts from buffer x.
     "xy     Yanks to buffer x.
     "xd     Deletes into buffer x.

  Undo, Redo, and Retrieve

     u       Undoes last change.
     U       Restores current line.
     .       Repeats last change.
     "dp     Retrieves dth last delete.

  EXAMPLES

    1.  To list all files saved during an editor crash, key in the following:

        vi -L


    2.  To recover the file vlp which was saved during an editor crash, key in
        the following:

        vi -r vlp


    3.  To edit the read-only file vlp assuming encryption, key in the
        following:

        vi -Rx vlp


    4.  To look up the tag main in the tags file and edits it, performing a
        search command when the file open, key in the following:

        vi -t main -c '/int a'




  2/94 - Intergraph Corporation                                              7






  vi(1)                               CLIX                               vi(1)



  FILES

    /tmp   The default directory where temporary work files are placed; it can
           be changed using the directory option.  (See the ex set command.)

    /usr/lib/terminfo/?/*
           The compiled terminal description database.

    /usr/lib/.COREterm/?/*
           A subset of compiled terminal description database.

  NOTES

    Although they continue to be supported, two flags have been replaced in
    the documentation by flags that follow the Command Syntax Standard.  (See
    intro(1)).  The -r flag with no argument has been replaced by -L, and
    +command has been replaced by -c command.

  CAUTIONS

    The vi editor does not support files larger than 32 MB.

    Software tabs using ^T work only immediately after the autoindent.

    Left and right shifts on intelligent terminals do not make use of the
    insert and delete character operations in the terminal.

    The encryption flags are provided with the Security Administration
    Utilities package, which is available only in the United States.

    Tampering with entries in the /usr/lib/.COREterm/?/* or
    /usr/lib/terminfo/?/* files (for example changing or removing an entry)
    can affect programs such as vi that expect the entry to be present and
    correct.  In particular, removing the ``dumb'' terminal may cause
    unexpected problems.

  EXIT VALUES

    Following are the exits values for the vi command:

    1   System error

    2   Other error

    0   Successful

    -1  User not found

  RELATED INFORMATION

    Commands:  ed(1), edit(1), ex(1)



  8                                              Intergraph Corporation - 2/94






  vi(1)                               CLIX                               vi(1)



    Functions:  curses(3)

    Files:  terminfo(4)

    AT&T UNIX System V vi User's Guide, AT&T UNIX System V vi Editing Guide

















































  2/94 - Intergraph Corporation                                              9




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026