




                                VVEE TTUUTTOORRIIAALL


                                 _R_i_c_o _T_u_d_o_r

                             rico@math.nwu.edu
                              29 January, 1996




_v_e  is  a  screen-oriented text editor  most systems,  the  interrupt  key  is
designed for expert users.  Most  com-  <<DDEELL>> or <<ccttrrll--CC>>.
mands  are  one  or  two  key strokes,
error messages are terse,  and  visual
distractions are minimized.  This does  LLOOOOKKIINNGG AARROOUUNNDD
not  mean  that  _v_e  is  difficult  to
learn;  it  is positively spartan com-  Text  displayed  by _v_e is stored in an
pared to the features and command sets  area called the ``text  buffer.''   To
of  some editors.  With a little prac-  look at a file, it must be copied into
tice, the commands  in  this  tutorial  the text buffer.   Maintained  at  all
will become second nature.              times  is  the current line and column
                                        in the buffer.  While  the  screen  is
                                        often  too  small  to  show the entire
GGEETTTTIINNGG IINN,, GGEETTTTIINNGG OOUUTT                 buffer, this ``current  position''  is
                                        always visible on the screen, as indi-
To  begin  your first editing session,  cated by the terminal's cursor.  First
type to the shell                       start _v_e, then type

  vvee                                      ::ee aannyyffiillee

and hit the <<RREETTUURRNN>> key.  You  should  and  then  type  <<RREETTUURRNN>>.  If _a_n_y_f_i_l_e
see                                     doesn't exist, the command  will  fail
                                        with the message
  ~~
  ~~                                       vvee:: ccaann''tt ooppeenn ffiillee
  ~~
                                        When  _v_e has read a file, you will see
on  the  bottom  three  lines  of  the  the first two  lines.   To  see  more,
screen.  If you  don't,  consult  your  type <<RREETTUURRNN>> a few times.  _v_e doesn't
administrator.   In  any case, try the  use all lines of  the  screen  at  the
quit command                            outset,  but  expands  the ``text win-
                                        dow'' when needed.  Commands  to  move
  ::qq                                    the current position include

and type  <<RREETTUURRNN>>.   All  ::  commands    <<RREETTUURRNN>>  go to the next line
require  a trailing <<RREETTUURRNN>>.  At this    ;;         go to the previous line
point,  you  should  be  back  in  the    GG         go to first line in buffer
shell.  A more forceful way to quit _v_e    99gg        go to line 9
is                                        gg         go to last line in buffer
                                          <<SSPPAACCEE>>   go right
  ::QQ                                      <<BBAACCKKSSPPAACCEE>>go left
                                          $$         go to the end-of-line
If things seem out  of  control,  type
<<EESSCC>>  or  interrupt  a few times.  On  It is not an error to go past the end-


                                   - 1 -






of-line.  Lines which are  beyond  the  save  the  changes to a file.  You may
end of the buffer appear on the screen  forget to do so, but _v_e will not;  the
as                                      command  ::qq  results in the error mes-
                                        sage
  ~~
                                          vvee:: tteexxtt nnoott ssaavveedd
The terminal bell rings after a  minor
error,  like attempting to go past the  You may  override  _v_e's  objection  by
end of the buffer.  Major  errors  are  quitting forcefully:
accompanied by a message at the bottom
of the screen.                            ::QQ

                                        Usually,  you  will  want to save your
CCRREEAATTIINNGG AA FFIILLEE                         work.  The command

There are two steps to creating a  new    ::ww aannyyffiillee
file  or  changing  an  existing  one.
First, the text buffer is  changed  as  writes the buffer to the  named  file.
desired.   Second, the buffer is saved  If  you  started  the  editing session
to the file.  If the  second  step  is  with a ::ee command like
not  performed, then your work will be
lost when you exit from _v_e.               ::ee aannyyffiillee

The easiest way to change  the  buffer  then you can save the  buffer  to  the
is to delete lines or characters:       remembered file name by simply typing

  dddd   delete the current line            ::ww
  xx    delete the current character
  33dddd  delete three lines               Did  you forget what file you're edit-
  33xx   delete three characters          ing?  Ask _v_e with

To insert new text, you first type        ::ff

  ii                                     After saving the buffer, a  normal  ::qq
                                        command  will return you to the shell.
Now everything you type is inserted at
the current position, even dddd  and  xx.
This  ``insert  mode'' continues until  RREECCOOVVEERRIINNGG FFRROOMM MMIISSTTAAKKEESS
you type
                                        This tutorial does not cover  all  the
  <<EESSCC>>                                 commands  and  capabilities of _v_e, but
                                        some features are too useful, and fun,
It is always safe to type <<EESSCC>>, which  to ignore.  Perhaps the most important
is  handy  if  you  can't remember the  is  the  ability  to  undo  any   text
current mode.  Another  way  to  start  change.   If you have made some sample
inserting text is to type               changes to your buffer, now type

  oo                                       uu

which  opens  a fresh line, and enters  By repeating  this  command,  you  can
insert mode.  In this mode,  your  tty  undo even more.  Eventually, you would
erase  and kill characters work in the  arrive at the beginning of the current
customary way, as  does  <<RREETTUURRNN>>  and  editing  session,  as indicated by the
the \\ character.                        message

Having  completed  all desired changes    vvee:: bbeeggiinnnniinngg--ooff--sseessssiioonn
to the buffer, the second step  is  to


                                   - 2 -






Similarly, you can undo the  undo,  or  The zone can be written to a file by
re-do, by typing a capital
                                          ::wwzz aannyyffiillee
  UU
                                        or deleted entirely by
By repeating this command, you eventu-
ally arrive at the most recent of your    ddzz
changes, as indicated by the message

  vvee:: eenndd--ooff--sseessssiioonn                    RREEPPEEAATTIINNGG AA CCOOMMMMAANNDD

You  can  think  of this activity as a  Any  command  that  changes the buffer
kind of time travel.  What you  travel  can be repeated by simply typing
along  is called the ``timeline.''  It
is important to realize that, when  in    ..
your ``past,'' it is possible and rea-
sonable to edit text.  When this  hap-  Note that uu and UU are never  repeated,
pens,  the  timeline  is  cut  and the  and  can  be  used  to  undo/redo  the
``future'' is discarded.                effects of the .. command.


ZZOONNEESS                                   LLOOOOKKIINNGG AATT BBIIGG FFIILLEESS

Another feature used widely in  _v_e  is  Moving the current position  one  line
the  ``zone.''   A zone is established  at  a  time  is tedious for big files.
by identifying one  or  more  adjacent  One way to save  time  is  to  give  a
lines in the buffer.  For example,      count:

  1122zz                                     88<<RREETTUURRNN>> go forward 8 lines
                                          88;;        go backward 8 lines
establishes a 12-line zone starting at
the current line, while                 You  can  also  use  the ``jump'' com-
                                        mands:
  kkaa99ggzzaa
                                          88jj   jump forward 8 lines
places a ``mark'' called aa on the cur-    88JJ   jump backward 8 lines
rent  line,  goes  to line 9, and then
establishes the  zone  from  the  line  If a jump command is typed  without  a
marked  aa  to  the  new  current line.  line count, it uses the previous.  For
Once you have a zone, you can go to  a  example, the sequence of commands
faraway line, and type
                                          88jj;;;;;;;;jj
  tt
                                        advances the current  position  by  12
A copy of the zone will be inserted at  lines.  Another way to advance quickly
the current line.  Typing               through a file is  by  "paging".   The
                                        current   size   of  the  text  window
  mm                                     defines the page size.  Try typing

moves, rather than copies, the  origi-    pp    advance to next page
nal  zone.  Indenting and, for lack of    PP    back up to previous page
a better word, exdenting  is  achieved    99pp   advance 9 pages
by                                        99PP   back up 9 pages

  >>                                     As mentioned earlier, the text  window
  <<                                     expands  according  to  use.   You can
                                        prevent this by ``locking''  the  win-


                                   - 3 -






dow:                                    ttooccccaattaa.  Searching can be constrained
                                        in a variety of ways:
  wwll
                                          ccaatt  matches ccaatt,, ccaatteerr,, dduuccaatt,, ttooccccaattaa
This  is useful for preserving the top    ~~ccaatt matches ccaatt,, ccaatteerr
part of the screen,  or  when  editing    ccaatt~~ matches ccaatt,, dduuccaatt
over  the  phone  at  slow speeds.  To    ~~ccaatt~~matches ccaatt
unlock the text window, type
                                        So,  to  search  forward for the exact
  wwLL                                    word ccaatt, type the command

You can also expand the text window to    //~~ccaatt~~
the full size of the screen with
                                        The ~~ is just one of  several  magical
  ww<<RREETTUURRNN>>                             punctuation characters.  Another is ^^,
                                        which constrains  the  search  to  the
                                        beginnings of lines:

SSEEAARRCCHHIINNGG                                 ^^ccaatt matches ccaatt...... or ccaatteerr......
                                          ^^ccaatt~~matches ccaatt ......
The  best  way  to  move through large
files is by searching.   This  assumes  The  $$ character constrains the search
you  have  some  idea of what the file  to the endings of lines:
contains, which is usually  the  case.
Try the command                           ccaatt$$ matches ......ccaatt or ......dduuccaatt
                                          ~~ccaatt$$matches ...... ccaatt
  //ccaatt
                                        The   remaining   magical   characters
and  don't  forget  the  <<RREETTUURRNN>>.  If  should be avoided for now:
these three letters do not occur  from
the current position to the end of the    [[   ..   **   \\
buffer, you will see the message
                                        Those  of  you familiar with ``regular
  vvee:: nnoo mmaattcchh                          expressions,'' as used by UNIX _e_d  and
                                        _g_r_e_p may wish to experiment further.
Otherwise, the cursor moves to the  cc.
You  can  repeat  the  search with one
keystroke                               CCOONNCCLLUUSSIIOONN

  ss                                     As you become familiar with _v_e and the
                                        commands described earlier, take  time
To search backwards to  the  beginning  to   peruse  the  file  _d_o_c_/_r_e_f_e_r_e_n_c_e_.
of the buffer, type                     This contains an extremely terse,  but
                                        complete,  description of commands and
  ??ccaatt                                  features.

or capital

  SS

In the above commands,

  ccaatt

is  called  the search pattern.  While
this pattern will find the  word  ccaatt,
it  will  also  find  dduuccaatt, ccaatteerr and


                                   - 4 -



