home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / unix / pv_vi109.arc / VI.DOC < prev   
Encoding:
Text File  |  1989-02-18  |  19.0 KB  |  964 lines

  1.           ------------------------------------------------------------
  2.  
  3.  
  4.                                  ===== VI =====
  5.  
  6.  
  7.           ------------------------------------------------------------
  8.  
  9.           --                  Free VI version 1.9a.                 --
  10.  
  11.           --         Copyright 1987, 1988, 1989 by Paul Vojta.      --
  12.  
  13.           --     This program may be freely distributed provided:   --
  14.  
  15.           --                                                        --
  16.  
  17.           --  1.  All files (vi.com, vi.doc, and read.me) are       --
  18.  
  19.           --      distributed together in unmodified form (use of   --
  20.  
  21.           --      universally available file compression software   --
  22.  
  23.           --      is allowed, however); and                         --
  24.  
  25.           --                                                        --
  26.  
  27.           --  2.  No fee is charged other than a nominal processing --
  28.  
  29.           --      charge or a connect time charge.                  --
  30.  
  31.           ------------------------------------------------------------
  32.  
  33.  
  34.  
  35.           VI is a screen text editor written for the IBM  PC.  It  has been
  36.  
  37.      given the same name as the screen editor for  the Berkeley  Unix oper-
  38.  
  39.      ating system.  This is no  coincidence:  with  a few  exceptions, this
  40.  
  41.      editor is a subset of the latter.  Users familiar  with Unix  can skip
  42.  
  43.      to the command summary at the end of this file.  (Unix is  a trademark
  44.  
  45.      of Bell Laboratories.)
  46.  
  47.  
  48.           This editor requires an 80-column display, MS-DOS 1.1  or higher,
  49.  
  50.      and 128K of memory.
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.      Getting started
  68.  
  69.      ------- -------
  70.  
  71.  
  72.           To edit an existing file, type
  73.  
  74.  
  75.                vi name
  76.  
  77.  
  78.      as a DOS command.  The first few lines of the file will then appear on
  79.  
  80.      the screen, and you may use any of the editing commands to  modify it.
  81.  
  82.      For example:
  83.  
  84.  
  85.           dw        delete a word
  86.  
  87.           de        delete a word, leaving punctuation
  88.  
  89.           dd        delete a line
  90.  
  91.           3dd       delete three lines
  92.  
  93.           itextEND  insert text
  94.  
  95.           /string   search for string
  96.  
  97.           xp        transpose characters (actually two commands)
  98.  
  99.  
  100.      In addition, all of the keys on the numeric keypad perform as labeled.
  101.  
  102.      When you are finished editing, type ZZ  or ":x"  to write  the correc-
  103.  
  104.      tions to disk and quit.   If no  corrections were  made, then  ZZ just
  105.  
  106.      quits.  To quit without saving corrections, use ":q!".
  107.  
  108.  
  109.           If the file named in the DOS command "vi name" does not exist, VI
  110.  
  111.      starts with an empty file, into which text can  be inserted.   This is
  112.  
  113.      how VI can be used to create a file.
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.      VI States
  134.  
  135.      -- ------
  136.  
  137.  
  138.           VI has three states, all of which occur  in at  least one  of the
  139.  
  140.      above commands.  They are,
  141.  
  142.  
  143.      o    Command mode.  This is  the normal  and initial  state.  All
  144.  
  145.           commands return here after completion.
  146.  
  147.  
  148.      o    Insert mode.  Characters typed  in insert  mode are,  as the
  149.  
  150.           name implies, copied into the file instead of interpreted as
  151.  
  152.           commands.  The "Escape", "End", and "Insert" keys  return VI
  153.  
  154.           to command mode (and vice versa for "Insert").  In this mode
  155.  
  156.           the cursor is larger than in command mode, in order  to help
  157.  
  158.           you keep track of the program's mode.
  159.  
  160.  
  161.      o    Last line mode.  In this mode the editor is reading text for
  162.  
  163.           a ":" command or a "/" or  "?" search.   The text  ends with
  164.  
  165.           <cr> or "Escape".  Control `U' deletes the text but  not the
  166.  
  167.           ":", "/", or "?" (unless there is no text).
  168.  
  169.  
  170.  
  171.      Counts Before VI Commands
  172.  
  173.      ------ ------ -- --------
  174.  
  175.  
  176.           Many VI commands can be preceded by a number.  The effect of this
  177.  
  178.      number is usually  to repeat  the effect  of the  command.  Sometimes,
  179.  
  180.      however, it has other meanings.  In many cases it is ignored.
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.      The Screen
  200.  
  201.      --- ------
  202.  
  203.  
  204.           The first 24 lines of the screen  are used  to display  the file;
  205.  
  206.      the last line is used for last line mode and for messages.  Lines past
  207.  
  208.      the  end of  the file  appear as  lines consisting  of a  single tilde
  209.  
  210.      ("~").  Tabs are expanded to columns 9, 17, 25, ..., 73, 1, ....  Long
  211.  
  212.      lines are wrapped around, so that they  may take  up several  lines of
  213.  
  214.      the screen.  "@" lines indicate that the next line is too long  to fit
  215.  
  216.      on the remainder of the screen.  The user should not create  lines too
  217.  
  218.      long to fit on a screen, although VI will not stop him from trying.
  219.  
  220.  
  221.           In case  DOS (or  a program  bug) scrambles  the screen,  ^L will
  222.  
  223.      restore it to what it should be.
  224.  
  225.  
  226.           If a command causes  the cursor  to move  to a  part of  the file
  227.  
  228.      which is not currently displayed on the screen, VI  will automatically
  229.  
  230.      scroll  as  necessary.   VI  also has  commands to  explicitly request
  231.  
  232.      scrolling:
  233.  
  234.  
  235.  
  236.           ^F or PgDn  Move the screen  Forward one  screenful, keeping
  237.  
  238.                       the  last  two lines  of the  old screen  as the
  239.  
  240.                       first two lines of the new.
  241.  
  242.           ^B or PgUp  Move Backwards one screenful.
  243.  
  244.           ^D          Move Down 1/2 screen.
  245.  
  246.           ^U          Move Up 1/2 screen.
  247.  
  248.           ^E          Move Down one line.
  249.  
  250.           ^Y          Move Up one line.
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.      Motion Commands
  266.  
  267.      ------ --------
  268.  
  269.  
  270.           The arrows on the numeric  keypad perform  as labeled.   Also, VI
  271.  
  272.      has a rich assortment  of other  commands to  move the  cursor.  These
  273.  
  274.      are:
  275.  
  276.  
  277.  
  278.           + or <cr>   Move the cursor to the first  nonblank character
  279.  
  280.                       of  the  next  line in  the file.   (All motions
  281.  
  282.                       referring to lines put the  cursor on  the first
  283.  
  284.                       nonblank character of that line.)
  285.  
  286.           -           Move to the previous line.
  287.  
  288.           $           Move to the end of the current line.
  289.  
  290.           0           Move to the beginning of the line.
  291.  
  292.  
  293.           fx          Find the next occurrence of the given character.
  294.  
  295.                       The search is limited to the current line.
  296.  
  297.           Fx          Same as fx, backwards.
  298.  
  299.           ;           Repeat the previous f or F.
  300.  
  301.  
  302.           /string<cr> Search  for  the  next  occurrence of  the given
  303.  
  304.                       string.   This  search  starts  at  the  current
  305.  
  306.                       position, but may wrap  around the  beginning of
  307.  
  308.                       the file.
  309.  
  310.           ?string<cr> Same as "/", searching backwards.
  311.  
  312.           n           Repeat last "/" or "?" search.
  313.  
  314.           N           Same as "n", in the opposite direction.
  315.  
  316.           H or Home   Move the cursor to the first line of the screen.
  317.  
  318.           M           Move to the middle line of the screen.
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.           L or End    Move to the last line of the screen.
  332.  
  333.           nG          Move to the <n>th line of the file.
  334.  
  335.           G           Move to the last line.
  336.  
  337.           %           Move  to the  matching parenthesis,  bracket, or
  338.  
  339.                       brace.
  340.  
  341.  
  342.  
  343.      The Delete Operator
  344.  
  345.      --- ------ --------
  346.  
  347.  
  348.           If one of the above motions is preceded by  the letter  "d", then
  349.  
  350.      VI will delete the text, from the  old position  to the  new position.
  351.  
  352.      This called an operator because it changes the  effect of  the ensuing
  353.  
  354.      motion  command.   The  repetition  count for  the motion  command may
  355.  
  356.      either precede or follow the "d"; the effect is the same.
  357.  
  358.  
  359.           Also,  "d"  may  be doubled  (i.e. dd  or 7dd)  to delete  one or
  360.  
  361.      several lines.  If D is capitalized, it deletes through the end of the
  362.  
  363.      line.
  364.  
  365.  
  366.           Other operators are "c" (change) and "y" (yank), described later.
  367.  
  368.  
  369.  
  370.      Other Deletion Commands
  371.  
  372.      ----- -------- --------
  373.  
  374.  
  375.           x or  Delete  Functions  the  same  as  dSpace;  deletes one
  376.  
  377.                       character.
  378.  
  379.           X           Deletes backwards one character; same as dh.
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.      Insert Mode
  398.  
  399.      ------ ----
  400.  
  401.  
  402.           A number of commands place the user in insert mode.  They are:
  403.  
  404.  
  405.  
  406.           i    Enter insert  mode, inserting  text before  the current
  407.  
  408.                character.
  409.  
  410.           a    Insert after the current character.
  411.  
  412.           A    Insert after end of line.
  413.  
  414.           o    Open a new line after the current line and enter insert
  415.  
  416.                mode.
  417.  
  418.           O    Open before current line.
  419.  
  420.           c<motion>, cc, C   "c" is an operator,  similar to  "d".  It
  421.  
  422.                deletes text and leaves the editor in insert mode.  For
  423.  
  424.                example,  "cw"  changes  the  current  word;  "cc", the
  425.  
  426.                current line.
  427.  
  428.  
  429.           To exit insert mode, use the  Esc key,  the Ins  key, or  the End
  430.  
  431.      key.  To delete all characters typed so far in the current  line, type
  432.  
  433.      Control U.  Insert  mode also  supports Control-W  to delete  the most
  434.  
  435.      recently typed word, and Control-V to strip the next character  of any
  436.  
  437.      special meaning.  In this version of vi, the  backspace key  will also
  438.  
  439.      allow you to delete a mistakenly typed carriage return.
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.      Other Modification Commands
  464.  
  465.      ----- ------------ --------
  466.  
  467.  
  468.  
  469.           rx   Replaces the current character with the character  x.
  470.  
  471.           J    Joins two lines; i.e. concatenates them, adding a space
  472.  
  473.                between them.
  474.  
  475.  
  476.  
  477.      Undo and Repeat
  478.  
  479.      ---- --- ------
  480.  
  481.  
  482.           In case of a mistake, the "u" command will undo the effect of the
  483.  
  484.      last command which modified the file.  Only the most recent change can
  485.  
  486.      be undone in this way.
  487.  
  488.  
  489.           The dot command (".") will repeat the last command  which changed
  490.  
  491.      the file.
  492.  
  493.  
  494.  
  495.      Moving Text
  496.  
  497.      ------ ----
  498.  
  499.  
  500.           To move part of a file, one  uses the  operations of  yanking and
  501.  
  502.      putting.  Yanking consists of copying part  of a  file into  a special
  503.  
  504.      buffer; putting copies that buffer into another part of the file.
  505.  
  506.  
  507.           To yank text, use the "y" operator (y<motion>, yy,  or Y)  in the
  508.  
  509.      same manner as the delete or change operators.   Then move  the cursor
  510.  
  511.      and use the put command (p) or put-before command (P) to put  the text
  512.  
  513.      elsewhere.  For example,
  514.  
  515.  
  516.                                    5G yy 9G p
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.      places another copy  of the  fifth line  of the  file after  the ninth
  530.  
  531.      line.
  532.  
  533.  
  534.           The delete and change operators also save the  deleted text  in a
  535.  
  536.      yank buffer.  Thus the command "xp" (actually two  commands) exchanges
  537.  
  538.      two  characters by  deleting the  first and  reinserting it  after the
  539.  
  540.      second.
  541.  
  542.  
  543.           In addition  to the  default yank  buffer, VI  has 26  other yank
  544.  
  545.      buffers, tagged by  (lower-case) letters  of the  alphabet.  To  let a
  546.  
  547.      yank, put, delete, or  change command  command refer  to one  of these
  548.  
  549.      buffers, precede the command with the quote  character and  the letter
  550.  
  551.      of the buffer.
  552.  
  553.  
  554.           Transferring text between  files can  be done  in one  of several
  555.  
  556.      ways.  First, the command
  557.  
  558.  
  559.                          :r name
  560.  
  561.  
  562.      reads  the named  file into  the current  file, following  the current
  563.  
  564.      line.
  565.  
  566.  
  567.           The reverse of this operation is the command,
  568.  
  569.  
  570.                          :p name
  571.  
  572.  
  573.      which puts the buffer into a file  of the  given name,  destroying the
  574.  
  575.      file's previous contents, if any.  "x:p and :"xp are also  valid; both
  576.  
  577.      do the same as :p with buffer x.
  578.  
  579.  
  580.           The last way of transferring text between files is to yank one or
  581.  
  582.      more pieces of text, switch the main file via
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.                          :e name
  596.  
  597.                       or :e! name
  598.  
  599.  
  600.      and then put the text into the new main file.
  601.  
  602.  
  603.  
  604.      Marking Positions in the File
  605.  
  606.      ------- --------- -- --- ----
  607.  
  608.  
  609.           You can mark your current position  in the  file by  typing `mx',
  610.  
  611.      where `x' may be any lower case letter.  You can  then return  to that
  612.  
  613.      spot by typing 'x to return to that line or `x to return to  the exact
  614.  
  615.      character.  Of course, you can also use 'x or `x in an operator, e. g.
  616.  
  617.      m'x or y`x.  Also, '' or `` will return to the  starting point  of the
  618.  
  619.      last `/', `?', `n', `N', `G', `H', `M', `L', `%', ``', or `'' motion.
  620.  
  621.  
  622.  
  623.      Helpful Hints
  624.  
  625.      ------- -----
  626.  
  627.  
  628.           In addition to ending insert and last line modes, the  Escape key
  629.  
  630.      can be used to delete a partially complete command.  It also momentar-
  631.  
  632.      ily enlarges the cursor.  This makes it easier to  see--it is  easy to
  633.  
  634.      lose the cursor after a locate operation.
  635.  
  636.  
  637.           To insert an escape code into the file, use control-[  or Alt-27,
  638.  
  639.      or precede it with ^V in insert mode.
  640.  
  641.  
  642.           One feature that VI currently lacks is the ability to  change all
  643.  
  644.      occurrences of a given  string to  another string.   This can  be done
  645.  
  646.      with  alternate  uses  of  the  "n"  and  "."  commands (and  a little
  647.  
  648.      patience).
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.           The current implementation of this  program lacks  the capability
  662.  
  663.      of editing files larger than will fit in memory under the small memory
  664.  
  665.      model.  That translates into about 50K.  If you reach that  limit, the
  666.  
  667.      program will display a message and suggest that you save  your correc-
  668.  
  669.      tions immediately.  It is strongly suggested  that you  do so,  as the
  670.  
  671.      editor will be in an unstable state; continuing to use it after such a
  672.  
  673.      message would likely result in loss  of data.   This is  indeed unfor-
  674.  
  675.      tunate, but at least it is better than earlier versions,  which termi-
  676.  
  677.      nated  immediately  and  lost all  corrections.  If  you need  to edit
  678.  
  679.      larger files, find the `split' utility (on a bulletin board  near you)
  680.  
  681.      or buy the MKS vi editor.
  682.  
  683.  
  684.  
  685.      ------------------------------------------------------------
  686.  
  687.  
  688.           The above is a tutorial introduction to some  of the  most common
  689.  
  690.      VI commands.  A list of all VI  commands appears  in the  command sum-
  691.  
  692.      mary, below.
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.                                 Command Summary
  728.  
  729.                                 ------- -------
  730.  
  731.  
  732.  
  733.      Colon commands:
  734.  
  735.  
  736.          :w [name]   write to file
  737.  
  738.          :q          quit
  739.  
  740.          :q!         abort
  741.  
  742.          :wq [name]  write and quit
  743.  
  744.          :e name     edit new file
  745.  
  746.          :x or ZZ    same as :q or :wq, depending on whether
  747.  
  748.                      corrections have been made
  749.  
  750.          :e! name    discard corrections and edit new file
  751.  
  752.          :f or ^G    print file name, status, and length
  753.  
  754.          :ve         print VI version
  755.  
  756.          :r name     read file into current file
  757.  
  758.          :["x]p name put to file
  759.  
  760.  
  761.  
  762.      Character motions:
  763.  
  764.  
  765.          h or Backspace  back <n> character(s)
  766.  
  767.          Space or l or Rightarrow   forward <n> characters
  768.  
  769.          j or ^N or Downarrow   down <n> lines, same column
  770.  
  771.          k or ^P or Uparrow     up <n> lines, same column
  772.  
  773.          $           down <n-1> lines, end of line
  774.  
  775.          0           beginning of line
  776.  
  777.          ^           first non-white character in line
  778.  
  779.          w           next <n> words
  780.  
  781.          b           back <n> words
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.          e           end of <n>th word from here
  794.  
  795.          W, B, E     same as w, b, e, with blank-delimited words
  796.  
  797.          |           move to column <n>
  798.  
  799.          %           match (), [], or {}.
  800.  
  801.          `x          character of mx command (x=any lower case letter)
  802.  
  803.          ``          start of last /?nNGHML%' or ` motion
  804.  
  805.  
  806.          /string     search
  807.  
  808.          ?string     backwards search
  809.  
  810.          /<cr> or ?<cr> forward or backwards search, same pattern
  811.  
  812.          n           repeat last search
  813.  
  814.          N           repeat last search, opposite direction
  815.  
  816.  
  817.          fx          find next <n>th occurrence of x
  818.  
  819.          Fx          find previous <n>th x
  820.  
  821.          tx          next <n>th x (not inclusive)
  822.  
  823.          Tx          previous <n>th x (not inclusive)
  824.  
  825.          ;           repeat last f, F, t, or T
  826.  
  827.          ,           reverse of ,
  828.  
  829.  
  830.  
  831.      Line motions:
  832.  
  833.  
  834.          + or <cr>   <n>th next line (first nonwhite)
  835.  
  836.          -           <n>th previous line
  837.  
  838.          _           current line or <n-1>st next line
  839.  
  840.          H or Home   top of screen (or <n>th line on screen)
  841.  
  842.          M           middle of screen
  843.  
  844.          L or End    last line of screen (or <n>th line from bottom)
  845.  
  846.          nG          go to <n>th line (end default)
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.          'x          line of mx command (x=any lower case letter)
  860.  
  861.          ''          start of last /?nNGHML%' or ` motion
  862.  
  863.  
  864.  
  865.      Operators:
  866.  
  867.  
  868.          d<motion>, dd, D   delete
  869.  
  870.          c<motion>, cc, C   change
  871.  
  872.          y<motion>, yy, Y   yank
  873.  
  874.                      (Note that in this implementation 'Y' is equivalent to
  875.  
  876.                      'y$' instead of 'yy').
  877.  
  878.  
  879.  
  880.      Insert Mode:
  881.  
  882.  
  883.          i or Insert insert before current character
  884.  
  885.          a           insert after current character
  886.  
  887.          I           insert before first nonblank character in line
  888.  
  889.          A           append to end of line
  890.  
  891.          o           open after current line
  892.  
  893.          O           open before current line
  894.  
  895.  
  896.  
  897.      Other modification commands:
  898.  
  899.  
  900.          x or Delete delete character; same as "d "
  901.  
  902.          X           delete previous character; same as "dh"
  903.  
  904.          s           delete character and enter insert mode;
  905.  
  906.                          same as "c "
  907.  
  908.          S           delete line and enter insert mode; same as "cc"
  909.  
  910.          r           replace character
  911.  
  912.          J           join two lines
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.          p           put yanked text
  926.  
  927.          P           put yanked text before current line or character
  928.  
  929.          u           undo previous command
  930.  
  931.          .           repeat previous command
  932.  
  933.  
  934.  
  935.      Screen commands:
  936.  
  937.  
  938.          ^L          redraw screen
  939.  
  940.          ^F or PgDn  forward <n> screens
  941.  
  942.          ^B or PgUp  back <n> screens
  943.  
  944.          ^U, ^D      up (or down) 1/2 screen
  945.  
  946.          ^Y, ^E      up (or down) <n> lines
  947.  
  948.          z<cr> or zh redraw with current line (or <n>th line) on top
  949.  
  950.          z. or zm    redraw with current line (or <n>th line) in middle
  951.  
  952.          z- or zl    redraw with current line (or <n>th line) at bottom
  953.  
  954.          z+          redraw with current bottom line (or <n>th line) at top
  955.  
  956.  
  957.  
  958.      Miscellaneous:
  959.  
  960.  
  961.          mx          mark here as mark `x' (Cf. 'x and `x above.)
  962.  
  963.                      (x = any lower case letter)
  964.