Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vi(1) — bsd — Apollo Domain/OS SR10.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ex(1)

edit(1)

VI(1)                                BSD                                 VI(1)



NAME
     vi - screen oriented (visual) display editor based on ex

SYNOPSIS
     vi [ -t tag ] [ -r file ] [ +command ] [ -l ] [ -wn ] name ...

DESCRIPTION
     vi is a display-oriented text editor based on ex(1).  Since vi runs the
     same code as ex(1), you can get to the command mode of ex(1) from within
     vi and vice versa.

     When using vi, changes you make to the file are reflected in what appears
     on the terminal screen.  The position of the cursor on the screen
     indicates the position within the file.  The UNIX Text Processing manual
     provides full details on the use of vi.

OPTIONS
     -t tag         Edit the file containing the tag and position the editor
                    at its definition.

     -r file        Recover file after an editor or system crash.  If file is
                    not specified, a list of all saved files is printed.

                    Note:  /usr/ex?.?preserve -a must be run before vi -r will
                    list the recoverable files created since the node was last
                    rebooted.  /usr/ex?.?preserve -a is usually run at boot-
                    time from /etc/rc.

     -l             Indent appropriately for LISP code, and modify (), {}, [[,
                    and ]] commands to have meaning for LISP.

     -wn            Set the default window size to n.

     +command       Force the editor to begin by executing the specified
                    command. If you omit command, vi initially positions the
                    cursor at the last line of the first file.

VI MODES
     Command        Normal and initial mode.  Other modes return to command
                    mode upon completion.  ESC (escape) is used to cancel a
                    partial command.

     Input          Entered by the following options a i A I o O c C s S R.
                    Arbitrary text may then be entered. Input mode is normally
                    terminated with ESC character, or abnormally with
                    interrupt.

     Last line      Reading input for : / ? or !; terminate with a carriage
                    return to execute, interrupt to cancel.

COMMAND SUMMARY
   Sample commands
                       Arrow keys move the cursor
     h j k l           Same as arrow keys
     itextESC          Insert text
     cwnewESC          Change word to new
     easESC            Pluralize word
     x                 Delete a character
     dw                Delete a word
     dd                Delete a line
     3dd               ... 3 lines
     u                 Undo previous change
     ZZ                Exit vi, saving changes
     :q!CR             Quit, discarding changes
     /textCR           Search for text
     CTRL/U CTRL/D     Scroll up or down
     :ex cmdCR         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 these ways:
     line/column number   z  G  |
     scroll amount        CTRL/D  CTRL/U
     repeat effect        Most of the rest


   Interrupting, canceling
     ESC               End insert or incomplete cmd
     DEL               (Delete or rubout) interrupts
     CTRL/L            Reprint screen if DEL scrambles it
     CTRL/R            Reprint screen if CTRL/L is -> key


   File manipulation
     :wCR              Write back changes
     :qCR              Quit
     :q!CR             Quit, discard changes
     :e nameCR         Edit file name
     :e!CR             Reedit, discard changes
     :e + nameCR       Edit, starting at end
     :e +nCR           Edit starting at line n
     :e #CR            Edit alternate file
     CTRL/^            Synonym for :e #
     CTRL/~            Synonym for :e # on some terminals
     :w nameCR         Write file name
     :w! nameCR        Overwrite file name
     :shCR             Run shell, then return
     :!cmdCR           Run cmd, then return
     :nCR              Edit next file in arglist
     :n argsCR         Specify new arglist
     CTRL/G            Show current file and line
     :ta tagCR         To tag file entry tag
     CTRL/]            :ta, following word is tag

     In general, any ex or ed command (such as substitute or global) may be
     typed, preceded by a colon and followed by a carriage return.

   File Locking
     :set al           Enable file locking
     :set noal         Disable file locking
     :set ab           Enable automatic backup file creation
     :set noab         Disable automatic backup file creation
     :set ro           Enable readonly mode
     :set noro         Disable readonly mode

   Positioning within file
     CTRL/F            Forward screen
     CTRL/B            Backward screen
     CTRL/D            Scroll down half screen
     CTRL/U            Scroll up half screen
     G                 Go to specified line (end default)
     /pat              Next line matching pat
     ?pat              Prev line matching pat
     n                 Repeat last / or ?
     N                 Reverse last / or ?
     /pat/+n           nth line after pat
     ?pat?-n           nth line before pat
     ]]                Next section/function
     [[                Previous section/function
     (                 Beginning of sentence
     )                 End of sentence
     {                 Beginning of paragraph
     }                 End of paragraph
     %                 Find matching ( ) { or }


   Adjusting the screen
     CTRL/L            Clear and redraw
     CTRL/R            Retype, eliminate @ lines
     zCR               Redraw, current at window top
     z-CR              ... at bottom
     z.CR              ... at center
     /pat/z-CR         pat line at bottom
     zn.CR             Use n line window
     CTRL/E            Scroll window down 1 line
     CTRL/Y            Scroll window up 1 line


   Marking and returning
     ``                Move cursor to previous context
     ''                ... at first non-white in line
     mx                Mark current position with letter x
     `x                Move cursor to mark x
     'x                ... at first non-white in line

   Line positioning
     H                 Top line on screen
     L                 Last line on screen
     M                 Middle line on screen
     +                 Next line, at first non-white
     -                 Previous line, at first non-white
     CR                Return, same as +
     down-arrow or j   Next line, same column
     up-arrow or k     Previous line, same column

   Character positioning
     ^                    First non white
     0                    Beginning of line
     $                    End of line
     h or ->              Forward
     l or <-              Backwards
     CTRL/H               Same as <-
     space                Same as ->
     fx                   Find x forward
     Fx                   f backward
     tx                   Up to x forward
     Tx                   Back upto x
     ;                    Repeat last f F t or T
     ,                    Inverse of ;
     |                    To specified column
     %                    Find matching ( { ) or }

   Words, sentences, paragraphs
     w                 Word forward
     b                 Back word
     e                 End of word
     )                 To next sentence
     }                 To next paragraph
     (                 Back sentence
     {                 Back paragraph
     W                 Blank delimited word
     B                 Back W
     E                 To end of W

   Corrections during insert
     CTRL/H            Erase last character
     CTRL/W            Erase last word
     erase             Your erase, same as CTRL/H
     kill              Your kill, erase input this line
     \                 Quotes CTRL/H, your erase and kill
     ESC               Ends insertion, back to command
     DEL               Interrupt, terminates insert
     CTRL/D            Backtab over autoindent
     |CTRL/D           Kill autoindent, save for next
     0CTRL/D           ... but at margin next also
     CTRL/V            Quote non-printing character


   Insert and replace
     a                 Append after cursor
     i                 Insert before cursor
     A                 Append at end of line
     I                 Insert before first non-blank
     o                 Open line below
     O                 Open above
     rx                Replace single char with x
     RtextESC          Replace 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, e.g., dd to
     affect whole lines.

     d                 Delete
     c                 Change
     y                 Yank lines to buffer
     <                 Left shift
     >                 Right shift
     !                 Filter through command
     =                 Indent for LISP


   Miscellaneous Operations
     C                 Change rest of line (c$)
     D                 Delete rest of line (d$)
     s                 Substitute chars (cl)
     S                 Substitute lines (cc)
     J                 Join lines
     x                 Delete characters (dl)
     X                 ... before cursor (dh)
     Y                 Yank lines (yy)


   Yank and Put
     Put inserts the text most recently deleted or yanked.  However, if a
     buffer is named, the text in that buffer is put instead.

     p                 Put back text after cursor
     P                 Put before cursor
     "xp               Put from buffer x
     "xy               Yank to buffer x
     "xd               Delete into buffer x


   Undo, Redo, Retrieve
     u                 Undo last change
     U                 Restore current line
     .                 Repeat last change
     "dp               Retrieve d'th last delete



NOTES
     In the Domain/OS BSD implementation of vi, the w (word) and ^] (tag)
     commands both recognize a $ as part of a word. The w command also
     recognizes a - as part of a word, if LISP mode is on.

BUGS
     Software tabs using CTRL/T work only immediately after the autoindent.

     Left and right shifts on intelligent terminals don't make use of insert
     and delete character operations in the terminal.

     The wrapmargin option can be fooled since it looks at output columns when
     blanks are typed.  If a long word passes through the margin and onto the
     next line without a break, then the line won't be broken.

     Wrapmargins should be from left, not right, margin.

     Insert/delete within a line can be slow if tabs are present on
     intelligent terminals, since the terminals need help in doing this
     correctly.

     Saving text on deletes in the named buffers is somewhat inefficient.

     The source command does not work when executed as :source; there is no
     way to use the :append, :change, and :insert commands, since it is not
     possible to give more than one line of input to a colon (:) escape.  To
     use these on a :global you must Q to ex command mode, execute them, and
     then reenter the screen editor with vi or open.

FILES
     /usr/lib/ex?.?strings    Error messages
     /usr/lib/ex?.?recover    Recover command
     /usr/lib/ex?.?preserve   Preserve command
     /etc/termcap             Terminal capability descriptions
     ~/.exrc                  Editor start-up file
     /tmp/Exnnnnn             Editor temporary
     /tmp/Rxnnnnn             Named buffer temporary
     /usr/preserve            Preservation directory

SEE ALSO
     ex(1), edit(1), termcap (5), environ (7),
     UNIX Text Processing.

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