TEACH VED                                     Revised A.Sloman Sept 1987

                   Using VED to create your own files
                   ==================================

It is assumed that you have already worked through TEACH TEACH, and that
you already know how to use the SCREENDOWN key to read a teach file.
This file introduces VED commands that go beyond what you learnt from
TEACH TEACH. In particular it shows you how to create your own files.

NB - In order to work through this teach file, you will need to make use
of a keyboard map showing where to find the different function keys on
your keyboard. Note that in many of the TEACH files the "angle brackets"
< ... > are used to indicate a key that has a name written on it, e.g.

    <ESC>  <RETURN>  <ENTER> <BACKSPACE> <LINEFEED> <LF>

When you see things like that you should not type the "<" and ">"
symbols. Just look for a key with that name on it.

It is strongly recommended that you make short notes as you read on, to
help you remember how VED works.


-- INTRODUCTION -------------------------------------------------------

VED is a program for creating and altering files. For example, all the
teach files were created with VED. Files are like documents in a filing
cabinet, except that they are stored on a magnetic disc attached to the
computer. In roughly the same way that a filing cabinet has separate
drawers, so the disc is divided into areas called directories. One of
these is your own personal directory, into which VED will put any files
that you create. In this way, your files will not be confused with
anyone else's. (VED knows which directory to use because you gave your
"login" name when you logged in.)

The disc is the computer's long term memory. The computer also has a
short term memory which is used when programs are running. You are now
reading a file which has been copied from the long term memory to the
short term memory in order for you to look at it. When you create files
using VED you work in the short term memory. From time to time you will
need to ensure that your file is copied from the short term to the long
term memory, so that you can access it if you come back again after
logging out.

Among the things you need to learn is how to start editing a file, how
to finish and save it on the disc, how to move around the file you are
editing, how to insert text, how to delete text, how to copy or move
bits from one part of the file to another. VED has commands for all of
these actions, and many more. Some of the commands are done by pressing
a special key. Some require you to press a sequence of keys. Some are
done by giving a command on the command line. The TEACH TEACH file that
you started with introduced examples of all these commands. If you have
trouble remembering them, you should go back to that file as follows:

    Press: the <ENTER> key
    type:  teach teach
    press: the <RETURN> key

When you have finished with that file you can QUIT it with the command
    Press: <ENTER>
    type:   q
    press: <RETURN>

to get back to this file.

Read on using the SCREENDOWN key.


-- TEACH AND VED COMMANDS ---------------------------------------------

VED and TEACH are two ways of calling up the same system - so you are
already partially familiar with VED. The POP-11 command

    teach window

tells the system that you want to use VED to look at the teach file
called WINDOW. (Remember - that was the one that told you about using
<ESC> w to see a larger window on the screen.)

Similarly, you can use the POP-11 command

    ved vednotes

to tell VED you want to work on a file of your own, called 'vednotes'.

There are two important differences between the TEACH and VED commands:

    1) TEACH looks for files in a special directory of teach files,
       while VED uses your own directory. (It is possible to make VED
       look elsewhere, but we won't go discuss that here.)

    2) VED allows you to put new files, or altered versions of old ones,
       into long-term storage in your directory on the disc.  Although
       TEACH permits you to change the copy of the teach file that you
       are looking at, it won't store the changed version on disc.  So
       you don't have to worry about damaging teach files.  No matter
       what you do to the text displayed on your screen, the copy of a
       TEACH file in long-term storage remains intact.

Since VED and TEACH are just different names for the same system, the
TEACH commands like SCREENUP work in VED too. The same applies to other
commands that you have already learned.


-- VEDKEYS --------------------------------------------------------------

Many terminals now have, besides the normal typewriter keys, additional
keys referred to as "function keys". They may have marks on them, like
F1, F2, F3, etc. Or they may have other symbols such as arrows or
letters.

These keys, when pressed, transmit special signals to the computer. VED
can be told to respond to such a signal by doing something that would
otherwise require you to press several keys. So pressing a function key
can save you time and effort.

You have already learnt from the TEACH TEACH file that there are keys
called SCREENDOWN and SCREENUP and other keys for moving the cursor
around. Depending on the terminal you are using there may also be keys
for moving a "word" at a time, left or right, deleting chunks of text,
"marking" a chunk of text, moving or copying a chunk of text, and
performing other tasks.

Your system administrator, tutor, or Poplog supplier should provide you
with a keyboard map for the kind of terminal you are using (unless VED
has not been customised for your terminal).

Most terminals do not have sufficient function keys for all the tasks
VED has to perform. There are two additional ways commands can be given.
One, which you have met from the first TEACH file, uses an ENTER
command. E.g. <ENTER> 1 jumps to the top of the file, and <ENTER> bye
can be used to leave POPLOG.

In addition some commands are based on special sequences of keys. These
will depend on how your terminal has been set up. The TEACH files will
assume certain defaults, but if you have had the editor converted to
emulate some other editor, then these facilities will not work for you,
and you will have to consult the appropriate manual.


-- CURSOR MOVEMENT -------------------------------------------------------

You should already know how to move the cursor about the file, using the
SCREENUP and SCREENDOWN keys and keys that do small moves up, down, left
and right: CHARUP, CHARDOWN, CHARLEFT, CHARRIGHT. On some terminals
there are also keys for diagonal moves, or for bigger moves in the eight
directions.

Near the SCREENUP and SCREENDOWN key there are usually SCREENLEFT and
TEXTRIGHT (or SCREENRIGHT) keys, with arrows.

One key that is often useful, is the <LINE FEED> key, marked LF on some
terminals. This positions the cursor at the beginning of the next line.
It can therefore sometimes be referred to as the NEXTLINE key. It's
effect is like CHARDOWN plus SCREENLEFT.

The WORDLEFT and WORDRIGHT keys are also useful for moving within a
line. Practice using all those cursor movement keys until you feel very
familiar with their operation.


-- INSERTING NEW TEXT ------------------------------------------------------

Inserting new text is very simple. You simply position the cursor at the
point where you want the new text to appear and then type in the new
text. Try doing that now. Put the cursor
here ->
and type your name, or anything else.

If you make a mistake, press the CHARDELETE key and see what happens.
CHARDELETE deletes the last character you typed, i.e. the character to
the LEFT of the cursor. (On some keyboards without a <DEL> key the
<BACKSPACE> or <BS> key is given this role.)

You can insert text in the middle of a line, and everything to the right
moves over to make space for the new text.

Try inserting letters here ->     in the middle of this line. Everything
moves to the right. If the line gets too big for the screen, it will
split automatically. Try making that happen. (This automatic splitting
will not happen when you use VED to create programs.)


-- DELETING TEXT ------------------------------------------------------

To remove text, position the cursor directly after the text to be
deleted and press the DELETE key once for each character you want to
remove. Just for practice remove the asterisks HERE: *****   Notice how
things on the right shift left to fill the vacant space. Also the cursor
keeps moving left as characters are deleted.


-- OTHER DELETE KEYS --------------------------------------------------

On many keyboards there is a key given the role of deleting the CURRENT
character i.e. the one the cursor is on. For accidental historical
reasons this is sometimes called the DOTDELETE key (the "dot" character
"." being used in some systems to denote "here".) The keyboard map may
say something like "DELETE CHAR HERE"

If you can find such a key on your keyboard map, put the cursor on the
"1" on the next line and repeatedly press the key:
    HERE-> 123456789.

This time the cursor does not move left as characters are deleted, but
things to the right of the cursor still move leftwards to fill the gap.

You can also delete a whole word at a time. Using the WORDLEFTDELETE and
WORDRIGHTDELETE keys. These may be marked on the top of your keyboard,
or on your keyboard map. Put the cursor on the middle of the line below
and experiment with those two keys.

    EXPERIMENT ON THIS LINE WITH THE KEYS FOR DELETING WORDS

Notice how they sometimes delete a space, sometimes a word and a space.
They do this in a manner that corresponds to the way the WORDLEFT and
WORDRIGHT keys move the cursor.

Look on your keyboard map for keys labelled
    CLEARHEAD             LINEDELETE            CLEARTAIL
or
    DELETE LINE LEFT      DELETE WHOLE LINE     DELETE LINE RIGHT

The first of these will delete the characters to the LEFT of the cursor,
on the same line (the HEAD of the line). The second will delete the
WHOLE line containing the cursor. The third deletes all characters to
the RIGHT of the cursor, INCLUDING the character at the cursor location
(the TAIL of the line). Experiment with these three keys by putting the
cursor in the middle of lines a few paragraphs up and pressing them so
that you become familiar with their action.

Try typing a line of text below this line then pressing the CLEARHEAD
key: HERE ->

On many terminals you can use CTRL-u as a CLEARHEAD key (i.e. hold down
the CTRL key, and tap the "U" key).


-- BREAKING LINES -----------------------------------------------------

The RETURN key has an effect that at may at first seem odd but is very
useful if you need to alter the layout of some text. Position the cursor
in the middle of some line and then press the RETURN key. As you will
see VED breaks the line into two; the part before the cursor stays where
it is and the part after the cursor is moved to a newly inserted line
below the current line. Try it. You can find out below how to join the
lines up again after breaking them.

You can also use the RETURN key to insert a new line in some text by
putting the cursor at the end of a line, then pressing RETURN. Try that
method of putting a new blank line above this one. I.e. go back to the
line (using CHARUP) then to the right hand end (using the TEXTRIGHT key
or CHARRIGHT). Then press RETURN. You'll get a new blank line. You can
remove it by pressing the CHARDELETE key.


-- MERGING LINES ------------------------------------------------------

If you press CHARDELETE (usually the <DEL> key) when the cursor is at the
beginning of a line, the 'gap between lines' is deleted; that is the
line with the cursor and the line above are joined together.

Put the cursor at the beginning of the next line
(this line) and press CHARDELETE.

Then press <RETURN> to break the lines again. Practice breaking and
joining lines.


-- AUTO-BREAK ---------------------------------------------------------

If you are typing in text and get close to the right hand side of the
screen then VED will insert a new line for you automatically. Try that
now. Position the cursor at the end of the next line and start typing in
words, without pressing the RETURN key. Do it over HERE ->
You'll see how VED automatically breaks the line.

(It doesn't do this when used for program files, whose names end with
'.p' or '.lsp' or '.pl' etc.)


-- LONG LINES ---------------------------------------------------------

If a line won't fit on the screen because it is too long, then VED will
display just the first part of the line. However, if you press the
CHARRIGHT key again and again the cursor will move to the right hand
side of the screen and all the text on the screen will scroll or
jump left in a manner analogous to the way it moves up with the CHARDOWN
key.

Put the cursor on THIS very long line and try pressing the CHARRIGHT key lots of times.
To bring back the cursor to the beginning of the next line, press LINE
FEED or SCREENLEFT. Notice how a long line is indicated by a mark on the
right of the screen.


-- INSERTING A NEW LINE IN THE MIDDLE OF TEXT -------------------------

Sometimes you want to go back to a piece of text and add something
starting on a new line. There are two common ways of doing this. One is
to use the <RETURN> key, as described above, and the other uses special
keys (if available on your keyboard map) for LINEBAOVE and LINEBELOW.
If you have such keys on your map, try putting the cursor in various
places and pressing the keys to see how they insert lines. The LINEBELOW
key does the same as TEXTRIGHT followed by RETURN. LINEABOVE does the
same as CHARUP, TEXTRIGHT, RETURN.

(You can also use SCREENRIGHT instead of TEXTRIGHT for these.)


-- USING <ESC> x TO SWITCH FILES --------------------------------------

When you start creating your own files you will need to be able to
switch between your own file and the teach file telling you what to do.
You can learn how to do that by looking at another TEACH file. Try

    <ENTER> teach switchwindow <RETURN>

You can finish that file with the command:

    <ENTER> q <RETURN>

Try looking at it now.

The TEACH SWITCHWINDOW file should explain to you how you can use the
<ESC> key followed by the X key to switch back and forth between two
files.

More generally, <ESC> x switches to the last file you were editing
before the current one. If that file is not already on the screen, then
it will be inserted in the upper half. You can subsequently use <ESC> x
to move between the two files on the upper and lower halves of the
screen.


-- REVISION QUESTIONS -------------------------------------------------

    How do you delete a character to the left of the cursor?
    How do you delete the character under the cursor?
    How do you delete the word to the left of the cursor?
    How do you delete the word to the right of the cursor?
    How do you delete part of a line to the left of the cursor?
    How do you break a line somewhere in the middle?
    How does VED indicate that a line is too long to be shown in full?
    What does the LF (or Linefeed) key do?
    How do you insert some characters in the middle of a line?
    How do you merge two lines?
    How do you insert a new line above or below the current line?
    How is <ESC> x used?

After you have learnt how, by reading on, put the answers to these
questions in a file called VEDNOTES, for future reference.


-- CREATING A FILE OF YOUR OWN ----------------------------------------

At last you are ready to start creating your own files!

Read all of this section carefully before doing any of the examples in
it. There are important instructions towards the end.

So far, all you've done is modify a copy of the teach file for VED. Now
is the time to try creating a file of your own. The first thing to do is
think up a name for your file. Filenames can have a mixture of letters
or digits in them. Exactly what sorts of characters can be included in a
file name depends on the operating system. VMS is far more restrictive
than UNIX, but unless you know exactly what you are doing it is a good
idea to include only letters, numbers, the dot "." and the underscore
"_" (not to be confused with the hyphen ("-"). Some versions of UNIX
(System V Unix) allow only 14 or fewer characters in a file name. If you
don't know the limits on the system you are using ask an expert.

WARNING: On Unix systems you will be allowed to create file names
containing special characters, but if you do you may later have
great difficulty deleting, copying, or printing the files. The
characters most likely to cause trouble include:

    question mark "?",  asterisk "*",   less than "<"
    greater than ">",   exclamation mark "!",
    vertical bar "|"    a space " "

In particular if you include "*" or "?" or a space in your file name on
UNIX, you may have a lot of trouble later trying to delete it without
deleting some of your OTHER files.

    foobaz              This is okay
    my_file             This is okay
    my-file             This is not recommended
    letter_to_my_mum    This is too long for some Unix systems.
    file3               This is okay
    3file               Some systems won't allow a number first
    secret              This is okay, but it's a give away name
    myprog.p            The 'suffix' tells VED that it is a POP-11 file
    program.pl          The 'suffix' indicates a Prolog file
    functions.lsp       The 'suffix' indicates a Lisp file

You could give your file a name based on your own name. E.g. if your
name is Sally you could call the file 'sally1'. (Use lower case rather
than capitals.) Alternatively if you are going to use your first file to
store notes on the editor, call it 'vednotes'.

Let's say that you've decided to call your first file sally1. To tell
VED that you want to work on a file called sally1 you can do the
following. (NB NB Don't do it till you've read up to the line with
asterisks below.)

    (a) Press: ENTER
    (b) Type:  ved sally1         (Use DELETE key to correct mistakes)
    (c) Press: RETURN

When you do this (assuming you don't yet have a file with the name you
have chosen) VED will tell you that it's starting a new file and clear
half the screen to give you a window to type in. This teach file (TEACH
VED) will still be visible on the other half of the screen.

    (d) You can then type in something, eg a summary of the VED
        commands, a poem, or any old nonsense.

Use the <ENTER> teach command, or <ESC> x to get back here.


-- SCROLLING THE "OTHER" FILE UP OR DOWN <ESC> LF and <ESC> BS --------

While you are typing in your own file, the cursor will be in the new
window and the SCREENUP and SCREENDOWN keys will move the cursor within
that window.

If you wish to read more of this file you can use <ESC> x (as explained
in TEACH SWITCHWINDOW) to come back to this file, then press SCREENDOWN
to get more of this file on the screen, then use <ESC> x to go back.

That can be a bit tedious, so VED has a "shorthand" method of doing
that by means of the <ESC> <LINEFEED>  (or <ESC> <LF>) sequence.

That is, you can still scroll THIS file in the other window, using <ESC>
<LINEFEED> to get the effect of SCREENDOWN. Try it by going to your
other file with <ESC> x then pressing <ESC> <LINEFEED> a few times to
read more of this.

You can also scroll the "other" file UPwards by using <ESC> followed by
the <BACKSPACE> key (sometimes marked BS).

So
    <ESC> <LINEFEED> is equivalent to:  <ESC> x SCREENUP <ESC> x

while

    <ESC> <BACKSPACE> is equivalent to: <ESC> x SCREENDOWN <ESC> x

Having read this far, go back and do the instructions (a), (b), (c),
then use <ESC> <LINEFEED> to read ahead in this file, while you are
writing in the other. To look back at an earlier portion of this file do
<ESC> <BACKSPACE> (or <BS>).


-- SUMMARY AND QUESTIONS ----------------------------------------------

It's a good idea to use your first file to type in a summary of what
you've learnt about using the editor. E.g. call it 'vednotes' and in it
type answers to these questions.

What do the following do:
    Pressing the ENTER button
    Pressing the CHARDELETE key in the middle of a line
    Pressing the CHARDELETE key at the beginning of a line
    Pressing the RETURN key with the cursor in middle of a line
    Typing ESC then w
    Typing ESC then x
    Typing ESC then pressing the LINE FEED key
    Typing ESC then pressing the BACK SPACE key
    Pressing the keypad keys on the right
    How do you delete a whole word at a time?
    How do you insert text?
    How do you split a line in the middle?
    How do you start creating a new file of your own?
    Which keys delete whole line, line to left, line to right?
    How do you quit a file?


-- SWITCHING BETWEEN A TEACH FILE AND YOUR OWN FILE -------------------

You may want to switch back and forth between reading this teach file
and editing your own file. You can get back to this file by:

    Press: ENTER
    Type:  teach
    Press: RETURN

You can get back to editing your own file by giving the command:
    ENTER ved

Just as the TEACH command remembers what teach file you are working on,
so the VED command remembers what file of your own you have most
recently been editing, if you give it no name.

Alternatively, the <ESC> x (eXchange files) command can be used.


-- PRINTING YOUR FILE --------------------------------------------------

When you have finished putting something in your file, you can ask the
computer to print it on the line printer, as follows:

    ENTER print

If there is a tutor or a demonstrator present ask him or her to show you
how to collect your print-out from the printer.


-- WRITING FILES TO THE DISC : <ENTER> w ------------------------------

Occasionally VED will "beep" and print out a message saying
'VEDAUTOWRITE' and put a copy of what you have done so far onto the
disc, so that your work is safely stored if something goes wrong, e.g.
there is a power failure and the machine suddenly stops.

You can force VED to save all your work so far on the disc, at any time,
by giving the
    <ENTER> w

command to "write" your files to the permanent store on the disc.
If you have only been looking at TEACH files it will do
nothing. But if you have been working on your own files it will see if
any of them have had any changes made since last being "written", and if
so it will write them, ie. save them on the disc. It is a good idea to
type
    <ENTER> w

every time you have made some significant changes to your file,
especially if you are temporarily stopping, e.g. to read something or
talk to someone. When you leave POPLOG with the '<ENTER> bye' command it
will write your files automatically. However, the "quit" command
'<ENTER> q' described below is different.


-- LEAVING A FILE WITH <ENTER> q --------------------------------------

If you have started typing a file in for practice and decide you don't
want it stored on the disc, then you should put the cursor into the file
concerned and give the command:

    ENTER q

(ie.. q for QUIT).

If you have typed or deleted something in the file, VED will check that
you really do want to abandon the result of your efforts. VED will say,
on the command line something like:

    FILE CHANGED. WRITE IT? Type 'y' OR 'n' OR 'c' TO CONTINUE

You should normally respond by pressing the Y key, i.e. say "YES" you
want VED to write the file on to the magnetic disc, so that you can get
at it again when you next log in. If the file contains only rubbish that
you don't want saved, You can press the N key to quit without saving the
file.

    <ENTER> q

Does not ask for confirmation when you quit a TEACH file. If you have
made some changes to it they will simply be ignored, so that next time
you look at the file it will be in its original state.

However, if you quit a file of your own after you have done something to
it, this could be a slip, and VED checks so that your work is not all
lost. Try the following:

    <ENTER> ved junkfile

(or choose a name of a file that you already have, but have not yet
done any work on). Then type in or delete some characters in the file.
Then do
    <ENTER> q

Because it is your own file, VED will say, on the command line:

         FILE CHANGED WRITE IT?  TYPE 'y' 'n' or 'c' TO CONTINUE

If you type just 'c' VED will abandon the QUIT command and the cursor
will go back to where it last was. Try that, i.e. <ENTER> q, then press
the C key. Then do <ENTER> q again, and this time type just 'n'. The
file will be abandoned and left as it was originally on the disk, if
there was one, or the new file you've created will not be stored. You
should only type 'n' when you really want to ABANDON the work you have
done. Normally you should type 'y' and your file will be saved on the
disk.

Try editing one of your files again, type something into it, do <ENTER>
q, then respond 'y'. You'll see VED say that it is writing the file. If
you then edit it again you will see that your changes are still there.

After quitting your file you can then leave POP-11 and log out, or do
something else.


-- LEAVING POPLOG WITH <ENTER> BYE ------------------------------------

If you've had enough for now and want to log out then you can leave VED
with the command:

    ENTER bye


-- Related TEACH files ------------------------------------------------

TEACH BUFFERS shows how you can switch between different files when you
have more than two files in the editor. You will want to do this once
you begin writing POP-11 programs, so you should read TEACH BUFFERS
next.

If you want to continue now, then quit this file and try

TEACH MARK   - this tells you how to mark ranges in a file.

Then if you want to use the editor for typing in programs, try

TEACH LMR    - this tells you how to COMPILE a marked range in a program
file.

TEACH VEDPOP  - gives you an introduction to using the editor to create
POP-11 programs.

If you are not interested in programming, try:

TEACH MOREVED - it describes some of the more advanced editing
facilities, including an introduction to searching commands in VED. If
you are developing programs it is not as important as TEACH MARK, LMR
and VEDPOP.


-- HELP FILES -----------------------------------------------------------

There is a command HELP, similar to TEACH, that gives you access to a
directory of help files.  Help files give brief descriptions of the
usage of various terms in POP-11, eg. HELP VED is a summary of VED
facilities for more experienced users.


-- USING <ENTER> g A TABLE OF CONTENTS --------------------------------

Read on to see how to use the table of contents below to jump to a
required portion of this file.

CONTENTS OF THIS FILE

 -- INTRODUCTION
 -- TEACH AND VED COMMANDS
 -- VEDKEYS
 -- CURSOR MOVEMENT
 -- INSERTING NEW TEXT
 -- DELETING TEXT
 -- OTHER DELETE KEYS
 -- BREAKING LINES
 -- MERGING LINES
 -- AUTO-BREAK
 -- LONG LINES
 -- INSERTING A NEW LINE IN THE MIDDLE OF TEXT
 -- USING <ESC> x TO SWITCH FILES
 -- REVISION QUESTIONS
 -- CREATING A FILE OF YOUR OWN
 -- SCROLLING THE "OTHER" FILE UP OR DOWN <ESC> LF and <ESC> BS
 -- SUMMARY AND QUESTIONS
 -- SWITCHING BETWEEN A TEACH FILE AND YOUR OWN FILE
 -- PRINTING YOUR FILE
 -- WRITING FILES TO THE DISC : <ENTER> w
 -- LEAVING A FILE WITH <ENTER> q
 -- LEAVING POPLOG WITH <ENTER> BYE
 -- Related TEACH files
 -- HELP FILES
 -- USING <ENTER> g A TABLE OF CONTENTS
 -- USING THE TABLE OF CONTENTS

-- USING THE TABLE OF CONTENTS ----------------------------------------

Many of POPLOG's teach and help files have an index formatted like the
above table of contents. Sometimes the index is at the beginning of the
file, rather than at the end, like this.

If you wish to go direct to a part of the file mentioned in the table,
you can put the cursor on the appropriate line in the table and then
press the key sequence:

    <ENTER> g <RETURN>

If you simply give that command now, then VED will jump to the start of
the index. Try it now, as follows, after you have read down to the row
of asterisks:

    Press <ENTER>
    Type g
    Press <RETURN>

This will take you to the top of the table. Move the cursor down to the
entry for a section you would like to look at again, using using the
CHARDOWN key, and then repeat the command
    <ENTER> g <RETURN>

to look at the section. To get back to the table use the same command.
Try all that now.

        ********************************************************

--- C.all/teach/ved
--- Copyright University of Sussex 1987. All rights reserved. ----------
