MirBSD manpage: 11.edit(USD)


                      Ex:  A Tutorial

                         Ricki Blau

                        James Joyce

                     Computing Services
                  University of California
                 Berkeley, California 94720

                          ABSTRACT

This narrative introduction to the use of the text editor ex
assumes  no  prior  familiarity  with computers or with text
editing. Its aim is to lead the beginning UNIX* user through
the fundamental steps of writing  and  revising  a  file  of
text.

     We welcome comments and suggestions about this tutorial
and the UNIX documentation in general.

September 1981

_________________________
*UNIX is a trademark of The Open Group.

USD:11-2                                      Ex: A Tutorial

                            Contents

Introduction   3

Session 1  4
     Making contact with UNIX   4
     Logging in  4
     Asking for ex   4
     The ``Command not found'' message   5
     A summary  5
     Entering text   5
     Messages from ex   5
     Text input mode   6
     Making corrections   6
     Writing text to disk   7
     Signing off  7

Session 2   8
     Adding more text to the file   8
     Interrupt   8
     Making corrections   8
     Listing what's in the buffer (p)   9
     Finding things in the buffer   9
     The current line   10
     Numbering lines (nu)   10
     Substitute command (s)   10
     Another way to list what's in the buffer (z)   11
     Saving the modified text   12

Session 3   13
     Bringing text into the buffer (e)   13
     Moving text in the buffer (m)   13
     Copying lines (copy)   14
     Deleting lines (d)   14
     A word or two of caution   15
     Undo (u) to the rescue   15
     More about the dot (.) and buffer end ($)   16
     Moving around in the buffer (+ and -)   16
     Changing lines (c)   17

Session 4   18
     Making commands global (g)   18
     More about searching and substituting   19
     Special characters   19
     Issuing UNIX commands from the editor   20
     Filenames and file manipulation   20
     The file (f) command   20
     Reading additional files (r)   21
     Writing parts of the buffer   21
     Recovering files   21
     Other recovery techniques   21
     Options, set, and editor startup files   22
     Further reading and other information   22

Ex: A Tutorial                                           USD:11-3

Index   23

USD:11-4                                           Ex: A Tutorial

                          Introduction

     Text editing using a terminal connected to a computer allows
you  to create, modify, and print text easily. A text editor is a
program that assists you as you create and modify text. The  text
editor you will learn here is named ex. Creating text using ex is
as easy as typing it on an electric  typewriter.  Modifying  text
involves telling the text editor what you want to add, change, or
delete. You can review your text by typing a command to print the
file contents as they are currently. Another program (which we do
not discuss in this document), a text formatter, rearranges  your
text for you into ``finished form.''

     These lessons assume no prior familiarity with computers  or
with  text editing. They consist of a series of text editing ses-
sions which lead you through the fundamental  steps  of  creating
and  revising  text. After scanning each lesson and before begin-
ning the next, you should try the examples at a terminal to get a
feeling  for the actual process of text editing. If you set aside
some time for experimentation, you will soon become familiar with
using  the  computer to write and modify text. In addition to the
actual use of the text editor, other features  of  UNIX  will  be
very  important  to your work. You can begin to learn about these
other features by reading one of the other tutorials that provide
a  general  introduction  to  the  system.  You  will be ready to
proceed with this lesson as soon as you  are  familiar  with  (1)
your  terminal  and  its special keys, (2) how to log in, (3) and
the ways of correcting typing errors.  Let's  first  define  some
terms:

program     A  set  of  instructions,  given  to  the   computer,
            describing  the  sequence  of steps the computer per-
            forms in order to accomplish  a  specific  task.  The
            task  must be specific, such as balancing your check-
            book or editing your text. A general  task,  such  as
            working  for world peace, is something we can all do,
            but not something we can currently write programs  to
            do.

UNIX        UNIX is a special type of program, called an  operat-
            ing  system,  that  supervises  the machinery and all
            other programs comprising the total computer system.

ex          ex is the name of the UNIX text editor  you  will  be
            learning  to  use,  and is a program that aids you in
            writing or revising text.

file        Each UNIX account is allotted space for the permanent
            storage  of  information,  such  as programs, data or
            text. A file is a logical unit of data, for  example,
            an  essay, a program, or a chapter from a book, which
            is stored on a computer system.  Once  you  create  a
            file,  it  is  kept  until you instruct the system to
            remove it. You may create  a  file  during  one  UNIX

Ex: A Tutorial                                           USD:11-5

            session,  end  the session, and return to use it at a
            later time. Files  contain  anything  you  choose  to
            write  and  store in them. The sizes of files vary to
            suit your needs; one file might hold  only  a  single
            number,  yet  another might contain a very long docu-
            ment or program. The only  way  to  save  information
            from  one  session  to  the  next is to store it in a
            file, which you will learn in Session 1.

filename    Filenames are  used  to  distinguish  one  file  from
            another,  serving  the  same purpose as the labels of
            manila folders in a file cabinet. In order  to  write
            or  access information in a file, you use the name of
            that file in a UNIX  command,  and  the  system  will
            automatically locate the file.

disk        Files are stored on an input/output device  called  a
            disk,  which  looks  something like a stack of phono-
            graph records. Each surface is coated with a material
            similar  to  that  on  magnetic  recording  tape, and
            information is recorded on it.

buffer      A temporary work space, made available  to  the  user
            for  the  duration  of  a session of text editing and
            used for creating and modifying the text file. We can
            think  of  the  buffer as a blackboard that is erased
            after each class, where each session with the  editor
            is a class.

USD:11-6                                           Ex: A Tutorial

                            Session 1

Making contact with UNIX

     To use the editor you must first make contact with the  com-
puter  by  logging  in to UNIX. We'll quickly review the standard
UNIX login procedure for the two ways you can make contact: on  a
terminal that is directly linked to the computer, or over a tele-
phone line where the computer answers your call.

Directly-linked terminals

     Turn on your terminal and press the RETURN key. You are  now
ready to log in.

Dial-up terminals

     If your terminal connects with the computer over a telephone
line,  turn  on the terminal, dial the system access number, and,
when you hear a high-pitched tone, place the telephone handset in
the  acoustic coupler, if you are using one. You are now ready to
log in.

Logging in

     The message inviting you to log in is:

          login:

Type your login name, which identifies you to UNIX, on  the  same
line  as the login message, and press RETURN. If the terminal you
are using has both upper and lower case, be sure you  enter  your
login  name  in  lower case; otherwise UNIX assumes your terminal
has only upper case and will not recognize lower case letters you
may  type.  UNIX  types  ``login:'' and you reply with your login
name, for example ``susan'':

          login: susan (and press the RETURN key)

(In the examples, input you would type appears in  bold  face  to
distinguish it from the responses from UNIX.)

     UNIX will next respond with a request for a password  as  an
additional  precaution  to prevent unauthorized people from using
your account. The password will not appear when you type  it,  to
prevent others from seeing it. The message is:

          Password:    (type your password and press RETURN)

If any of the information you gave during the login sequence  was
mistyped or incorrect, UNIX will respond with

Ex: A Tutorial                                           USD:11-7

          Login incorrect
          login:

in which case you should start the login process  anew.  Assuming
that you have successfully logged in, UNIX will print the message
of the day and eventually will present you  with  a  `%'  at  the
beginning  of  a  fresh  line.  The `%' is the UNIX prompt symbol
which tells you that UNIX is ready to accept a command.

Note: users of ksh(1) will instead be prompted with a `$'.

Asking for ex

     You are ready to tell UNIX that you want to  work  with  ex,
the  text  editor.  Now is a convenient time to choose a name for
the file of text you are about to create. To begin  your  editing
session,  type  ex  followed by a space and then the filename you
have selected; for  example,  ``text''.  After  that,  press  the
RETURN key and wait for ex's response:

          % ex text    (followed by a RETURN)
          text: new file: line 1
          :

If you typed the command correctly, you will now be in communica-
tion  with  ex.  Ex has set aside a buffer for use as a temporary
working space during your current editing session. Since ``text''
is  a  new  file  we are about to create the editor was unable to
find that file, which it confirms by saying:

          text: new file: line 1

On the next line appears ex's prompt `:', announcing that you are
in  command  mode  and ex expects a command from you. You may now
begin to create the new file.

The ``Command not found'' message

     If you misspelled ex by  typing,  say,  ``ec'',  this  might
appear:

          % ec
          ec: Command not found.
          %

Your mistake in calling ex  ``ec''  was  treated  by  UNIX  as  a
request  for  a  program  named ``ec''. Since there is no program
named ``ec'', UNIX reported that the program  was  ``not  found''
(but  be careful, there is a program named ``ed''). A new % indi-
cates that UNIX is ready for another command, and  you  may  then
enter the correct command.

USD:11-8                                           Ex: A Tutorial

A summary

     Your exchange with UNIX as you logged in  and  made  contact
with ex should look something like this:

          login: susan
          Password:
          ... A Message of General Interest ...
          % ex text
          text: new file: line 1
          :

Entering text

     You may now begin entering text into  the  buffer.  This  is
done  by  appending  (or adding) text to whatever is currently in
the buffer. Since there is nothing in the buffer at  the  moment,
you  are  appending  text  to  nothing;  in effect, since you are
adding text to nothing you are creating text. Most edit  commands
have  two equivalent forms: a word that suggests what the command
does, and a shorter abbreviation of  that  word.  Many  beginners
find the full command names easier to remember at first, but once
you are familiar with editing you may prefer to type the  shorter
abbreviations.  The  command to input text is ``append''. (It may
be abbreviated `a'.) Type append and press the RETURN key.

          % ex text
          :append

Messages from ex

     If you make a mistake in entering a command and  type  some-
thing  that ex does not recognize, it will respond with a message
intended to help you diagnose your error.  For  example,  if  you
misspell  the  command  to input text by typing, perhaps, ``add''
instead of ``append'' or `a', you will receive this message:

          :add
          The add command is unknown
          :

When you receive a diagnostic message, check what  you  typed  in
order  to  determine  what  part of your command confused ex. The
message above means that ex was unable to recognize your mistyped
command  and,  therefore,  did not execute it. Instead, a new `:'
appeared to let you know that ex is again ready to execute a com-
mand.

Text input mode

     By giving the command ``append'' (or using the  abbreviation
`a'),  you  entered  text  input mode, also known as append mode.

Ex: A Tutorial                                           USD:11-9

When you enter text input mode, ex stops sending  you  a  prompt.
You  will not receive any prompts or error messages while in text
input mode. You can enter pretty much anything you  want  on  the
lines.  The  lines  are  transmitted one by one to the buffer and
held there during the editing session. You  may  append  as  much
text  as  you want, and when you wish to stop entering text lines
you should type a period as the only character on  the  line  and
press  the RETURN key. When you type the period and press RETURN,
you signal that you want to stop appending text, and ex  responds
by allowing you to exit text input mode and reenter command mode.
Ex will again prompt you for a command by printing `:'.

     Leaving append mode does not destroy the text in the buffer.
You  have  to  leave  append mode to do any of the other kinds of
editing, such as changing, adding, or printing text. If you  type
a  period  as the first character and type any other character on
the same line, ex will believe you want to remain in append  mode
and  will  not  let  you out. As this can be very frustrating, be
sure to type only the period and the RETURN key.

     This is a good place to learn an important lesson about com-
puters  and  text:  a blank space is a character as far as a com-
puter is concerned. If you so much as type a period followed by a
blank  (that is, type a period and then the space bar on the key-
board), you will remain in append mode with the last line of text
being:

          .

Let's say that you enter the lines (try to type exactly what  you
see, including ``thiss''):

          This is some sample text.
          And thiss is some more text.
          Text editing is strange, but nice.
          .

The last line is the period followed by a RETURN  that  gets  you
out of append mode.

Making corrections

     If you have read a general introduction to  UNIX,  you  will
recall  that  it is possible to erase individual letters that you
have typed. This is done by typing the designated erase character
as many times as there are characters you want to erase.

     The usual erase character varies from  place  to  place  and
user to user.  Often it is the backspace, so you can correct typ-
ing errors in the line you are typing  by  typing  the  backspace
key.   (Sometimes it is the DEL key.) If you type the erase char-
acter you will notice that the terminal backspaces  in  the  line
you are on. You can backspace over your error, and then type what
you wanted.

USD:11-10                                          Ex: A Tutorial

     If you make a bad start in a line and would  like  to  begin
again,  you  will have to backspace to the beginning of the line,
or you can use `^U' to erase everything on the line:

          Text edtiing is strange, but^U
          Text editing is strange, but nice.

When you type `^U', you erase the entire line typed  so  far  and
are  given  a fresh line to type on. You may immediately begin to
retype the line. Additionally, `^W' may be  used  to  delete  the
last  word typed. These methods, unfortunately, do not work after
you type the line and press RETURN. To make corrections in  lines
that have been completed, it is necessary to use the editing com-
mands covered in the next sessions.

Writing text to disk

     You are now ready to edit the text.  One common operation is
to  write  the  text  to disk as a file for safekeeping after the
session is over. This is the only way to  save  information  from
one  session  to the next, since the editor's buffer is temporary
and will last only until the end of the editing session. Learning
how  to  write  a  file  to  disk is second in importance only to
entering the text. To write the contents of the buffer to a  disk
file, use the command ``write'' (or its abbreviation `w'):

          :write

Ex will copy the contents of the buffer to a disk  file.  If  the
file does not yet exist, a new file will be created automatically
and the presence of a ``[new file]'' will be  noted.  The  newly-
created  file  will  be given the name specified when you entered
the editor, in this case ``text''. To confirm that the disk  file
has  been  successfully  written, ex will repeat the filename and
give the number of lines and the total number  of  characters  in
the  file. The buffer remains unchanged by the ``write'' command.
All of the lines that were written to disk will still be  in  the
buffer, should you want to modify or add to them.

     Ex must have a name for the file to be written. If you  for-
got  to  indicate  the name of the file when you began to edit, a
temporary filename will be used. However, if you end your editing
session  without  writing  your  changes to a non-temporary file,
they will be lost. In this case, you can specify the filename  in
a new write command:

          :write text

After the ``write'' (or `w'), type a space and then the  name  of
the file.

Signing off

     We have done enough for this first lesson on using the  UNIX

Ex: A Tutorial                                          USD:11-11

text  editor,  and are ready to quit the session with edit. To do
this we type ``quit'' (or `q') and press RETURN:

          :write
          text: new file: 3 lines, 90 characters
          :quit
          %

The % is from UNIX to tell you that your session with ex is  over
and you may command UNIX further. Since we want to end the entire
session at the terminal, we also  need  to  exit  from  UNIX.  In
response to the UNIX prompt of ``%'' type the command

          %logout

This will end your session with UNIX, and will ready the terminal
for  the  next user. It is always important to type logout at the
end of a session to make absolutely sure no  one  could  acciden-
tally stumble into your abandoned session and thus gain access to
your files, tempting even the most honest of souls.

Note: ksh(1) users may have to type exit to end their session.

     This is the end of the first session on UNIX text editing.

USD:11-12                                          Ex: A Tutorial

                            Session 2

     Log in with UNIX as in the first session:

          login: susan  (carriage return)
          Password:       (give password and carriage return)

          ... A Message of General Interest ...
          %

When you indicate you want to edit, you can specify the  name  of
the file you worked on last time. This will start ex working, and
it will fetch the contents of the file into the buffer,  so  that
you can resume editing the same file. When ex has copied the file
into the buffer, it will repeat its name and report  the  current
line number (generally the last line of the file). Thus,

          % ex text
          text: unmodified: line 3
          :

means you asked ex to fetch the file named ``text'' for  editing,
causing  it  to  copy  the  text  into the buffer. Ex awaits your
further instructions, and indicates this by its prompt character,
the  colon  (:). In this session, we will append more text to our
file, print the contents of the buffer, and learn to  change  the
text of a line.

Adding more text to the file

     If you want to add more to the end of your text you  may  do
so  by  using  the  append command to enter text input mode. When
``append'' is the first command  of  your  editing  session,  the
lines  you  enter are placed at the end of the buffer. Here we'll
use the abbreviation for the append command, `a':

          :a
          This is text added in Session 2.
          It doesn't mean much here, but
          it does illustrate the editor.
          .

You may recall that once you enter append mode using the `a'  (or
``append'')  command,  you  need to type a line containing only a
period (.) to exit append mode.

Interrupt

     Should you press the `^C' key while working with ex, it will
send this message to you:

          Interrupted
          :

Ex: A Tutorial                                          USD:11-13

Any command that ex might be executing  is  terminated  by  `^C',
causing  ex to prompt you for a new command. If you are appending
text at the time, you will exit from append mode and be  expected
to  give  another  command. The line of text you were typing when
the append command was interrupted will not be entered  into  the
buffer.

Making corrections

     If while typing the line you hit an  incorrect  key,  recall
that  you may delete the incorrect character or cancel the entire
line of input by erasing in the usual way. Refer  either  to  the
last  few pages of Session 1 if you need to review the procedures
for making a correction. The most important idea to  remember  is
that erasing a character or cancelling a line must be done before
you press the RETURN key.

Listing what's in the buffer (p)

     Having appended text to what you wrote  in  Session  1,  you
might  want to see all the lines in the buffer. To print the con-
tents of the buffer, type the command:

          :1,$p

The `1' stands for line 1 of the buffer; the  `$'  is  a  special
symbol  designating  the  last line of the buffer; and `p' is the
print command. Thus this command prints from line 1 to the end of
the buffer. The command ``1,$p'' gives you:

          This is some sample text.
          And thiss is some more text.
          Text editing is strange, but nice.
          This is text added in Session 2.
          It doesn't mean much here, but
          it does illustrate the editor.

     Additionally, the percentage symbol (`%') may be used  as  a
shorthand for `1,$'. Thus the commands `%p' and `1,$p' are ident-
ical.

     Occasionally, you may accidentally  type  a  character  that
can't  be  printed, which can be done by striking a key while the
CTRL key is pressed. In printing lines, ex uses a  special  nota-
tion  to  show  the existence of non-printing characters. Suppose
you had introduced the non-printing character ``control-A''  into
the word ``illustrate'' by accidently pressing the CTRL key while
typing `a'. This can happen on many terminals  because  the  CTRL
key and the `A' key are beside each other. If your finger presses
between the two keys, control-A results. When asked to print  the
contents of the buffer, edit would display

          it does illustr^Ate the editor.

USD:11-14                                          Ex: A Tutorial

To represent the control-A, ex shows `^A'. The sequence `^'  fol-
lowed by a capital letter stands for the one character entered by
holding down the CTRL key and typing  the  letter  which  appears
after  the  `^'. We'll soon discuss the commands that can be used
to correct this typing error.

     In looking over the text we see that ``this''  is  typed  as
``thiss''  in the second line, a deliberate error so we can learn
to make corrections. Let's correct the spelling.

Finding things in the buffer

     In order to change something in the buffer we first need  to
find  it.  We  can  find ``thiss'' in the text we have entered by
looking at a listing of the lines. Physically speaking, we search
the  lines  of text looking for ``thiss'' and stop searching when
we have found it. The way to tell ex to search for  something  is
to type it inside slash marks:

          :/thiss/

By typing /thiss/ and pressing RETURN, you instruct ex to  search
for  ``thiss''. If you ask ex to look for a pattern of characters
which it cannot find in the buffer, it will respond ``Pattern not
found''.  When  ex  finds the characters ``thiss'', it will print
the line of text for your inspection:

          And thiss is some more text.

Ex is now positioned in the buffer at the line it  just  printed,
ready to make a change in the line.

Ex: A Tutorial                                          USD:11-15

The current line

     Ex keeps track of the line in the buffer where it is located
at all times during an editing session. In general, the line that
has been most  recently  printed,  entered,  or  changed  is  the
current  location  in  the buffer. The editor is prepared to make
changes at the current location in the buffer, unless you  direct
it to another location.

     In particular, when you bring a file into  the  buffer,  you
will  be  located  at the last line in the file, where the editor
left off copying the lines from the file to the buffer.  If  your
first  editing  command  is  ``append'',  the lines you enter are
added to the end of the file, after the current line -  the  last
line in the file.

     You can refer to your current location in the buffer by  the
symbol  period (.) usually known by the name ``dot''. If you type
`.' and carriage return you will be instructing ex to  print  the
current line:

          :.
          And thiss is some more text.

     If you want to know the number of the current line, you  can
type  .=  and  press  RETURN,  and  ex will respond with the line
number:

          :.=
          2

If you type the number of any line  and  press  RETURN,  ex  will
position you at that line and print its contents:

          :2
          And thiss is some more text.

You should experiment with these commands to gain  experience  in
using them to make changes.

Numbering lines (nu)

     The number (nu) command is similar to print, giving both the
number  and  the text of each printed line. To see the number and
the text of the current line type

          :nu
               2  And thiss is some more text.

Note that the shortest abbreviation for  the  number  command  is
``nu''  (and not `n', which is used for a different command). You
may specify a range of lines to be listed by the  number  command
in  the same way that lines are specified for print. For example,

USD:11-16                                          Ex: A Tutorial

1,$nu lists all lines in the buffer with their corresponding line
numbers.

Substitute command (s)

     Now that you have found the misspelled word, you can  change
it  from ``thiss'' to ``this''. As far as ex is concerned, chang-
ing things is a matter of substituting one thing for another.  As
a  stood  for append, so s stands for substitute. We will use the
abbreviation `s' to reduce the chance of mistyping the substitute
command. This command will instruct ex to make the change:

          2s/thiss/this/

We first indicate the line to be changed, line 2, and  then  type
an  `s' to indicate we want ex to make a substitution. Inside the
first set of slashes are the characters that we want  to  change,
followed  by  the  characters to replace them, and then a closing
slash mark. To summarize:

          2s/ what is to be changed / what to change it to /

If ex finds an exact match of the characters  to  be  changed  it
will  make the change only in the first occurrence of the charac-
ters. If it does not find the characters to be changed,  it  will
respond:

          No match found

indicating that your instructions could not be carried out.  When
ex does find the characters that you want to change, it will make
the substitution and automatically print  the  changed  line,  so
that you can check that the correct substitution was made. In the
example,

          :2s/thiss/this/
          And this is some more text.

line 2 (and line 2 only) will  be  searched  for  the  characters
``thiss'',  and  when  the  first exact match is found, ``thiss''
will be changed to ``this''. Strictly speaking, it was not neces-
sary above to specify  the number of the line to be changed. In

          :s/thiss/this/

ex will assume that we mean to  change  the  line  where  we  are
currently located (`.'). In this case, the command without a line
number would have  produced  the  same  result  because  we  were
already located at the line we wished to change.

     For another illustration of the substitute command,  let  us
choose the line:

          Text editing is strange, but nice.

Ex: A Tutorial                                          USD:11-17

You can make this line a bit more  positive  by  taking  out  the
characters ``strange, but '' so the line reads:

          Text editing is nice.

A command that will first position ex at  the  desired  line  and
then make the substitution is:

          :/strange/s/strange, but //

What we have done here is combine our search with  our  substitu-
tion. Such combinations are perfectly legal, and speed up editing
quite a bit once you get used to them. That is, you do not neces-
sarily  have  to  use  line  numbers  to  identify  a line to ex.
Instead, you may identify the line you want to change  by  asking
ex  to  search  for a specified pattern of letters that occurs in
that line. The parts of the above command are:

/strange/          tells ex to find the characters ``strange'' in the text
s                  tells ex to make a substitution
/strange, but //   substitutes nothing at all for the characters ``strange, but ''

     You should note the space after ``but'' in  ``/strange,  but
/''.  If  you  do not indicate that the space is to be taken out,
your line will read:

          Text editing is  nice.

which looks a little funny because of  the  extra  space  between
``is''  and  ``nice''.  Again,  we realize from this that a blank
space is a real character to a computer, and in editing  text  we
need  to  be  aware  of  spaces within a line just as we would be
aware of an `a' or a `4'.

Another way to list what's in the buffer (z)

     Although the print command is useful for looking at specific
lines  in  the  buffer, other commands may be more convenient for
viewing large sections of text. You can ask to see a screen  full
of text at a time by using the command z. If you type

          :1z

ex will start with line 1 and continue printing  lines,  stopping
either  when the screen of your terminal is full or when the last
line in the buffer has been printed. If you want to read the next
segment of text, type the command

          :z

If no starting line number is given for the z  command,  printing
will  start  at  the ``current'' line, in this case the last line

USD:11-18                                          Ex: A Tutorial

printed. Viewing lines in the buffer one screen full at a time is
known  as  paging.  Paging can also be used to print a section of
text on a hard-copy terminal.

Saving the modified text

     This seems to be a good place to pause in our work,  and  so
we  should  end the second session. If you (in haste) type `q' to
quit the session your dialogue with ex will be:

        :q
        File modified since last complete write; write or use ! to override
        :

This is ex's warning that you have not written the modified  con-
tents  of the buffer to disk. You run the risk of losing the work
you did during the editing session since  you  typed  the  latest
write command. Because in this lesson we have not written to disk
at all, everything we have done would have been lost  if  ex  had
obeyed  the  q command. If you did not want to save the work done
during this editing session, you would have  to  type  ``q!''  or
(``quit!'')  to confirm that you indeed wanted to end the session
immediately, leaving the file as it was  after  the  most  recent
``write''  command. However, since you want to save what you have
edited, you need to type:

          :w
          text: 6 lines, 171 characters

and then follow with the commands to quit and logout:

          :q
          % logout

and hang up the phone or turn off the terminal when UNIX asks for
a  name. Terminals connected to the port selector will stop after
the logout command, and pressing keys on  the  keyboard  will  do
nothing.

     This is the end of the second session on UNIX text editing.

Ex: A Tutorial                                          USD:11-19

                            Session 3

Bringing text into the buffer (e)

     Log in to UNIX and make contact with ex. You should  try  to
log  in without looking at the notes, but if you must then by all
means do.

     Did you remember to give the name of the file you wanted  to
edit? That is, did you type

          % ex text

or simply

          % ex

Both ways get you in contact with ex,  but  the  first  way  will
bring  a  copy of the file named ``text'' into the buffer. If you
did forget to tell ex the name of your file, you can get it  into
the buffer by typing:

          :e text
          text: unmodified: line 6

The command edit, which may be abbreviated e, tells ex  that  you
want  to  erase  anything that might already be in the buffer and
bring a copy of the file ``text'' into the  buffer  for  editing.
You may also use the edit (e) command to change files in the mid-
dle of an editing session, or to give ex the name of a  new  file
that  you  want  to  create.  Because the edit command clears the
buffer, you will receive a warning if you try to edit a new  file
without  having  saved  a  copy of the old file. This gives you a
chance to write the contents of the buffer to disk before editing
the next file.

Moving text in the buffer (m)

     Ex allows you to move lines of text from one location in the
buffer to another by means of the move (m) command. The first two
examples are for illustration only, though after  you  have  read
this  Session you are welcome to return to them for practice. The
command

          :2,4m$

directs ex to move lines 2, 3, and 4 to the  end  of  the  buffer
($).  The  format  for  the  move command is that you specify the
first line to be moved, the last line to be moved, the move  com-
mand  `m',  and  the  line  after  which  the moved text is to be
placed. So,

          :1,3m6

USD:11-20                                          Ex: A Tutorial

would instruct ex to move lines 1  through  3  (inclusive)  to  a
location  after line 6 in the buffer. To move only one line, say,
line 4, to a location in the buffer after  line  5,  the  command
would be ``4m5''.

     Let's move some text using the command:

          :5,$m1
          it does illustrate the editor.

After executing the move command, ex prints the last  moved  line
for  your  inspection. If you want to see more than just the last
line, you can then use the print (p), z, or number (nu)  commands
to view more text. The buffer should now contain:

          This is some sample text.
          It doesn't mean much here, but
          it does illustrate the editor.
          And this is some more text.
          Text editing is nice.
          This is text added in Session 2.

You can restore the original order by typing:

          :4,$m1

or, combining context searching and the move command:

          :/And this is some/,/This is text/m/This is some sample/

(Do not type both examples here!) The problem with combining con-
text  searching with the move command is that your chance of mak-
ing a typing error in such a long command is greater than if  you
type line numbers.

Copying lines (copy)

     The copy command is used to make a second copy of  specified
lines,  leaving  the original lines where they were. Copy has the
same format as the move command, for example:

          :2,5copy $

makes a copy of lines 2 through 5, placing the added lines  after
the  buffer's  end  ($). Experiment with the copy command so that
you can become familiar with how it works. Note that the shortest
abbreviation  for  copy  is co (and not the letter `c', which has
another meaning).

Deleting lines (d)

     Suppose you want to delete the line

          This is text added in Session 2.

Ex: A Tutorial                                          USD:11-21

from the buffer. If you  know  the  number  of  the  line  to  be
deleted,  you  can type that number followed by delete or d. This
example deletes line 4, which is ``This is text added in  Session
2.'' if you typed the commands suggested so far.

          :4d
          It doesn't mean much here, but

Here `4' is the number of the line to be deleted, and  ``delete''
or  `d'  is  the  command to delete the line. After executing the
delete command, ex prints the line that has  become  the  current
line (`.').

     If you do not happen to know the line number you can  search
for the line and then delete it using this sequence of commands:

          :/added in Session 2./
          This is text added in Session 2.
          :d
          It doesn't mean much here, but

The ``/added in Session 2./'' asks ex to  locate  and  print  the
line  containing  the  indicated text, starting its search at the
current line and moving line by line until  it  finds  the  text.
Once  you are sure that you have correctly specified the line you
want to delete, you can enter the delete  (d)  command.  In  this
case it is not necessary to specify a line number before the `d'.
If no line number is given, ex deletes the  current  line  (`.'),
that  is,  the line found by our search. After the deletion, your
buffer should contain:

          This is some sample text.
          And this is some more text.
          Text editing is nice.
          It doesn't mean much here, but
          it does illustrate the editor.
          And this is some more text.
          Text editing is nice.
          This is text added in Session 2.
          It doesn't mean much here, but

To delete both lines 2 and 3:

          And this is some more text.
          Text editing is nice.

you type

          :2,3d

which specifies the range of lines from 2 to 3, and the operation
on those lines - `d' for delete.

     The previous example assumes that you know the line  numbers

USD:11-22                                          Ex: A Tutorial

for  the lines to be deleted. If you do not you might combine the
search command with the delete command:

          :/And this is some/,/Text editing is nice./d

A word or two of caution

     In using the search function to locate lines to  be  deleted
you  should  be  absolutely  sure  the characters you give as the
basis for the search will take ex to the line you  want  deleted.
Ex  will search for the first occurrence of the characters start-
ing from where you last edited - that is, from the line  you  see
printed if you type dot (.).

     A search based on too few characters may result in the wrong
lines  being  deleted,  which  ex will do as easily as if you had
meant it. For this reason, it is usually  safer  to  specify  the
search  and then delete in two separate steps, at least until you
become familiar enough with using the editor that you  understand
how best to specify searches. For a beginner it is not a bad idea
to double-check each command before pressing RETURN to  send  the
command on its way.

Undo (u) to the rescue

     The undo (u) command has the ability to reverse the  effects
of the last command that changed the buffer. To undo the previous
command, type `u' or ``undo''. Undo can rescue  the  contents  of
the  buffer from many an unfortunate mistake. However, its powers
are not unlimited, so it is still wise to be  reasonably  careful
about the commands you give.

     It is possible to undo only commands which have the power to
change the buffer - for example, delete, append, move, copy, sub-
stitute, and even undo itself. The commands write  (w)  and  edit
(e),  which  interact  with disk files, cannot be undone, nor can
commands that do not change  the  buffer,  such  as  print.  Most
importantly, the only command that can be reversed by undo is the
last ``undo-able'' command you typed.

     To illustrate, let's issue an undo command. Recall that  the
last  buffer-changing  command we gave deleted the lines formerly
numbered 2 and 3. Typing undo at this  moment  will  reverse  the
effects  of  the deletion, causing those two lines to be replaced
in the buffer.

          :u
          And this is some more text.

Here again, ex prints the text of the line which is  now  ``dot''
(the current line).

Ex: A Tutorial                                          USD:11-23

More about the dot (.) and buffer end ($)

     The function assumed by the symbol dot depends on  its  con-
text. It can be used:

     1.  to exit from append mode; we type dot (and only  a  dot)
     on a line and press RETURN;

     2.  to refer to the line we are at in the buffer.

Dot can also be combined with the equal sign to get the number of
the line currently being edited:

          :.=

If we type `.=' we are asking for the number of the line, and  if
we type `.' we are asking for the text of the line.

     In this editing session and the last,  we  used  the  dollar
sign to indicate the end of the buffer in commands such as print,
copy, and move. The dollar sign as a command asks edit  to  print
the  last line in the buffer. If the dollar sign is combined with
the equal sign ($=) edit will print the line number corresponding
to the last line in the buffer.

     `.'  and  `$',  then,  represent  line   numbers.   Whenever
appropriate,  these  symbols can be used in place of line numbers
in commands. For example

          :.,$d

instructs edit to delete all lines from the current line  (.)  to
the end of the buffer.

Moving around in the buffer  (+ and -)

     When you are editing you often want to go back and re-read a
previous  line. You could specify a context search for a line you
want to read if you remember some of its text, but if you  simply
want  to  see  what  was written a few, say 3, lines ago, you can
type

          -3p

This tells ex to move back to  a  position  3  lines  before  the
current line (.) and print that line. You can move forward in the
buffer similarly:

          +2p

instructs ex to print the line that is 2 ahead  of  your  current
position.

     You may use `+' and `-' in any command  where  edit  accepts

USD:11-24                                          Ex: A Tutorial

line  numbers. Line numbers specified with `+' or `-' can be com-
bined to print a range of lines. The command

          :-1,+2copy$

makes a copy of 4 lines:  the current line, the line  before  it,
and  the  two after it. The copied lines will be placed after the
last line in the buffer ($), and the original lines  referred  to
by `-1' and `+2' remain where they are.

     Try typing only `-'; you will move back one line just as  if
you  had typed `-1p'. Typing the command `+' works similarly. You
might also try typing a few plus or minus signs in a row (such as
``+++'')  to  see ex's response. Typing RETURN alone on a line is
the equivalent of typing ``+1p''; it will move you one line ahead
in the buffer and print that line.

     If you are at the last line of the buffer and  try  to  move
further ahead, perhaps by typing a `+' or a carriage return alone
on the line, ex will remind you that you are at the  end  of  the
buffer:

          Illegal address: only 6 lines in the file

Similarly, if you try to move to  a  position  before  the  first
line, ex will print a message similar to:

          The print command doesn't permit an address of 0

The  number  associated  with  a  buffer  line  is   the   line's
``address'', in that it can be used to locate the line.

Changing lines (c)

     You can also delete certain lines and  insert  new  text  in
their  place. This can be accomplished easily with the change (c)
command. The change command  instructs  ex  to  delete  specified
lines  and then switch to text input mode to accept the text that
will replace them. Let's say you want to  change  the  first  two
lines in the buffer:

          This is some sample text.
          And this is some more text.

to read

          This text was created with the UNIX text editor.

To do so, you type:

          :1,2c
          This text was created with the UNIX text editor.
          .
          :

Ex: A Tutorial                                          USD:11-25

In the command 1,2c we specify that we want to change  the  range
of  lines  beginning  with  1  and  ending  with 2 by giving line
numbers as with the print command. These lines will  be  deleted.
Any  text  typed on the following lines will be inserted into the
position where lines were deleted by the change command. You will
remain  in  text  input  mode until you exit in the usual way, by
typing a period alone on a line. Note that the  number  of  lines
added  to  the buffer need not be the same as the number of lines
deleted.

     This is the end of the third session on  text  editing  with
UNIX.

USD:11-26                                          Ex: A Tutorial

                            Session 4

     This lesson covers several topics,  starting  with  commands
that  apply  throughout the buffer, characters with special mean-
ings, and how to issue UNIX commands while  in  the  editor.  The
next  topics  deal  with  files: more on reading and writing, and
methods of recovering files lost in a crash.  The  final  section
suggests sources of further information.

Making commands global (g)

     One disadvantage to the commands we have used for  searching
or  substituting  is  that if you have a number of instances of a
word to change it appears that  you  have  to  type  the  command
repeatedly,  once  for  each time the change needs to be made. Ex
however, provides a way to make commands apply to the entire con-
tents of the buffer - the global (g) command.

     To print all lines containing a certain sequence of  charac-
ters (say, ``text'') the command is:

          :g/text/p

The `g' instructs ex to make a global search for all lines in the
buffer  containing  the  characters  ``text''. The `p' prints the
lines found.

     To issue a global command, start by typing a `g' and then  a
search pattern identifying the lines to be affected. Then, on the
same line, type the command to be  executed  for  the  identified
lines.  Global  substitutions are frequently useful. For example,
to change  all  instances  of  the  word  ``text''  to  the  word
``material''  the  command  would  be a combination of the global
search and the substitute command:

          :g/text/s/text/material/g

Note the `g' at the end of the global  command,  which  instructs
edit   to   change   each  and  every  instance  of  ``text''  to
``material''. If you do not type the `g' at the end of  the  com-
mand  only  the  first  instance of ``text'' in each line will be
changed (the normal result of the substitute command). The `g' at
the  end  of  the command is independent of the `g' at the begin-
ning. You may give a command such as:

          :5s/text/material/g

to change every instance of ``text'' in line  5  alone.  Further,
neither  command will change ``text'' to ``material'' if ``Text''
begins with a capital rather than a lower-case `t'.

     Ex does not automatically print the lines modified by a glo-
bal  command.  If you want the lines to be printed, type a `p' at

Ex: A Tutorial                                          USD:11-27

the end of the global command:

          :g/text/s/text/material/gp

You should be careful about using the global command in  combina-
tion with any other - in essence, be sure of what you are telling
edit to do to the entire buffer. For example,

          :g/ /d

will delete every line containing a blank anywhere  in  it.  This
could  adversely  affect  your  document,  since  most lines have
spaces between words and thus would be deleted. Fortunately,  the
undo  command  can  reverse  the effects of a global command. You
should experiment with the global command on a small file of text
to see what it can do for you.

More about searching and substituting

     In using slashes to identify a character string that we want
to search for or change, we have always specified the exact char-
acters. There is a less tedious way to repeat the same string  of
characters. To change ``text'' to ``texts'' we may type either

          :/text/s/text/texts/

as we have done in the past, or a somewhat abbreviated command:

          :/text/s//texts/

In this example, the characters to be changed are not specified -
there  are no characters, not even a space, between the two slash
marks that indicate what is to be changed. This lack  of  charac-
ters between the slashes is taken by the editor to mean ``use the
characters  we  last  searched  for  as  the  characters  to   be
changed.''

     Similarly, the last context search may be repeated by typing
a pair of slashes with nothing between them:

          :/does/
          It doesn't mean much here, but
          ://
          it does illustrate the editor.

(You should note that the search  command  found  the  characters
``does''  in  the  word ``doesn't'' in the first search request.)
Because no characters are specified for the  second  search,  the
editor scans the buffer for the next occurrence of the characters
``does''.

     Ex normally searches forward through  the  buffer,  wrapping
around  from  the  end  of the buffer to the beginning, until the
specified character string is found. If you want to search in the

USD:11-28                                          Ex: A Tutorial

reverse direction, use question marks (`?') instead of slashes to
surround the characters you are searching for.

     It is also possible to repeat the last substitution  without
having to retype the entire command. An ampersand (`&') used as a
command repeats the most recent  substitute  command,  using  the
same  search and replacement patterns. After altering the current
line by typing

          :s/text/texts/

you type

          :/text/&

or simply

          ://&

to make the same change on the next line in the buffer containing
the characters ``text''.

Special characters

     Some characters have special meanings when used in  specify-
ing  searches.  `$'  is  taken by the editor to mean ``end of the
line'' and is used to identify strings that occur at the end of a
line.

          :g/text.$/s//material./p

tells the editor to search for all lines ending in ``text.'' (and
nothing  else,  not  even  a  blank  space), to change each final
``text.'' to ``material.'', and print the changed lines.

     The symbol `^' indicates the beginning of a line. Thus,

          :s/^/1. /

instructs the editor to insert ``1.'' and a space at  the  begin-
ning of the current line.

     The characters `$' and `^' have special meanings only in the
context  of  searching. At other times, they are ordinary charac-
ters. If you ever need to search for a character that has a  spe-
cial  meaning,  you  must  indicate that the character is to lose
temporarily its special significance by  typing  another  special
character, the backslash (\), before it.

          :s/\$/dollar/

looks for the character `$' in the current line and  replaces  it
by  the  word  ``dollar''. Were it not for the backslash, the `$'
would have represented ``the end of the  line''  in  your  search

Ex: A Tutorial                                          USD:11-29

rather  than the character `$'. The backslash retains its special
significance unless it is preceded by another backslash.

For a complete list of special characters, see the "Ex  Reference
Manual", /usr/share/doc/usd/14.exref/.

Issuing UNIX commands from the editor

     After creating several files with the editor, you  may  want
to delete files no longer useful to you or ask for a list of your
files. Removing and listing files are not functions of  the  edi-
tor,  and  so  they require the use of UNIX system commands (also
referred to as ``shell'' commands, as ``shell'' is  the  name  of
the  program  that  processes  UNIX commands). You do not need to
quit the editor to execute a UNIX command as long as you indicate
that it is to be sent to the shell for execution. To use the UNIX
command rm to remove the file named ``junk'' type:

          :!rm junk
          !
          :

The exclamation mark (`!') indicates that the rest of the line is
to  be  processed as a shell command. If the buffer contents have
not been written since the last change, a warning will be printed
before the command is executed:

          File modified since last write.

The editor prints a `!' when  the  command  is  completed.  Other
tutorials  describe  useful  features  of the system, of which an
editor is only one part.

Filenames and file manipulation

     Throughout each editing session, ex keeps track of the  name
of the file being edited as the current filename. Ex remembers as
the current filename the name given when you entered the  editor.
The  current  filename  changes  whenever the edit (e) command is
used to specify a new  file.  Once  ex  has  recorded  a  current
filename,  it inserts that name into any command where a filename
has been omitted. If a write command does not specify a file,  ex
as  we have seen, supplies the current filename. If you are edit-
ing a file named ``draft3'' having 283 lines in it, you can  have
the  editor  write onto a different file by including its name in
the write command:

          :w chapter3
          chapter3: new file: 283 lines, 8698 characters

The current filename remembered by the editor will not be changed
as a result of the write command. Thus, if the next write command
does not specify a name, edit will write onto  the  current  file
(``draft3'') and not onto the file ``chapter3''.

USD:11-30                                          Ex: A Tutorial

The file (f) command

     To ask for the  current  filename,  type  file  (or  f).  In
response,  the  editor  provides  current  information  about the
buffer, including the filename, your current position, the number
of  lines  in the buffer, and the percent of the distance through
the file your current location is.

          :f
          text: modified: line 3 of 4 [75%]

If the contents of the buffer have changed since  the  last  time
the  file was written, the editor will tell you that the file has
been ``modified:''. After you save the changes by writing onto  a
disk file, the buffer will no longer be considered modified:

          :w
          text: 4 lines, 88 characters
          :f
          text: unmodified: line 3 of 4 [75%]

Reading additional files (r)

     The read (r) command allows you to add  the  contents  of  a
file  to  the buffer at a specified location, essentially copying
new lines between two existing lines. To use it, specify the line
after  which  the  new text will be placed, the read (r) command,
and then the name of the file. If you have a file  named  ``exam-
ple'', the command

          :$r example
          example: 18 lines, 473 characters

reads the file ``example'' and adds it to the  buffer  after  the
last  line.  The current filename is not changed by the read com-
mand.

Writing parts of the buffer

     The write (w) command can write all or part of the buffer to
a  file  you  specify.  We  are already familiar with writing the
entire contents of the buffer to a disk file. To write only  part
of  the  buffer  onto  a  file, indicate the beginning and ending
lines before the write command, for example

          :45,$w ending

Here all lines from 45 through the end of the buffer are  written
onto  the  file  named  ending. The lines remain in the buffer as
part of the document you are editing, and  you  may  continue  to
edit  the entire buffer. Your original file is unaffected by your
command to write part of the buffer to another file.  Edit  still
remembers  whether  you  have saved changes to the buffer in your

Ex: A Tutorial                                          USD:11-31

original file or not.

Recovering files

     Although it does not happen very often, there are times UNIX
stops  working  because  of  some  malfunction. This situation is
known as a crash. Under most circumstances, ex's  crash  recovery
feature  is  able  to  save work to within a few lines of changes
before a crash (or a remote connection timeout). If you lose  the
contents  of  an  editing buffer in a system crash, you will nor-
mally receive mail when you log in that gives  the  name  of  the
recovered  file.  To  recover the file, enter the editor and type
the command recover (rec), followed by the name of the lost file.
For example, to recover the buffer for an editing session involv-
ing the file ``chap6'', the command is:

          :recover chap6

Recover is sometimes unable to save the  entire  buffer  success-
fully, so always check the contents of the saved buffer carefully
before writing it back onto the original file. For best  results,
write  the buffer to a new file temporarily so you can examine it
without risk to the original file. Unfortunately, you cannot  use
the  recover  command  to  retrieve  a file you removed using the
shell command rm.

Other recovery techniques

     If something goes wrong when you are using  the  editor,  it
may  be  possible to save your work by using the command preserve
(pre), which saves the buffer as if the system  had  crashed.  If
you   are  writing  a  file  and  you  get  the  message  ``Quota
exceeded'', you have tried to  use  more  disk  storage  than  is
allotted  to  your  account.  Proceed  with caution because it is
likely that only a part of the editor's buffer is now present  in
the  file  you  tried  to  write. In this case you should use the
shell escape from the editor (!) to remove some files  you  don't
need and try to write the file again. If this is not possible and
you cannot find someone to help you, enter the command

          :preserve

and wait for the reply,

          File preserved

If you do not receive this reply, seek help immediately.  Do  not
simply  leave the editor. If you do, the buffer will be lost, and
you may not be able to save your file. If  the  reply  is  ``File
preserved''  you  can leave the editor (or log out) to remedy the
situation. After a preserve, you can use the recover command once
the  problem  has been corrected, or the -r option of the ex com-
mand if you leave the editor and want to return.

USD:11-32                                          Ex: A Tutorial

     If you make an undesirable change to the buffer and  type  a
write  command before discovering your mistake, the modified ver-
sion will replace any previous version of the  file.  Should  you
ever  lose a good version of a document in this way, do not panic
and leave the editor. As long as you stay in the editor, the con-
tents of the buffer remain accessible. Depending on the nature of
the problem, it may be possible to restore the buffer to  a  more
complete  state  with  the undo command. After fixing the damaged
buffer, you can again write the file to disk.

Options, set, and editor startup files

     The editor has a set of options, some  of  which  have  been
mentioned above. The most useful options are given in the follow-
ing table.

     The options are of three  kinds:   numeric  options,  string
options,  and  toggle  options.   You  can set numeric and string
options by a statement of the form

        set opt=val

and toggle options can be set or unset by statements  of  one  of
the forms

        set opt
        set noopt

Name         Default    Description
_______________________________________________________________________________
autoindent   noai       Supply indentation automatically
autowrite    noaw       Automatic write before :n, :ta, ^^, !
ignorecase   noic       Ignore case in searching
list         nolist     Tabs print as ^I; end of lines marked $
magic        magic      . [ and * are special in scans
number       nonu       Lines prefixed with line numbers
report       report=5   Number of line which editor reports after changes.
shiftwidth   sw=8       Shift distance for <, > and ^D and ^T
term         $TERM      The kind of terminal you are using.

These statements can be placed in your EXINIT  in  your  environ-
ment,  or  given while you are running ex by typing them at the :
prompt and following them with a CR.

     You can get a list of all options which you have changed  by
the  command  :setCR, or the value of a single option by the com-
mand :set opt?CR. A list of all possible options and their values
is  generated  by :set allCR. Set can be abbreviated se. Multiple
options can be placed on one line, e.g. :se ai aw nuCR.

     Options set by the set command only last while you  stay  in
the  editor.  It  is  common  to want to have certain options set
whenever you use the editor. This can be accomplished by creating

Ex: A Tutorial                                          USD:11-33

a  list  of  commands which are to be run every time you start up
ex. For example:

        set ai ic report=1

sets the options autoindent, ignorecase, and report (to the value
of  1).  This  string  should be placed in the variable EXINIT in
your environment. If you use the shell csh, put this line in  the
file .login in your home directory:

        setenv EXINIT 'set ai ic report=1'

If you use the standard shell sh, put these  lines  in  the  file
.profile in your home directory:

        export EXINIT='set ai ic report=1'

Of course, the particulars of the  line  would  depend  on  which
options you wanted to set.

Further reading and other information

     These lessons are intended to introduce you  to  the  editor
and  its  more commonly-used commands. We have not covered all of
the editor's commands, but a selection of commands that should be
sufficient to accomplish most of your editing tasks. You can find
out more about the editor in the Ex Reference Manual. One way  to
become  familiar  with  the  manual  is  to  begin by reading the
description of commands that you already know.

                              Index

addressing, see line numbers       disk, 3
ampersand, 20                      documentation, 3, 23
append mode, 6-7                   dollar ($), 10, 11, 17, 20-21
append (a) command, 6, 7, 9        dot (.) 11, 17
``At end of file'' (message), 18   edit (text editor), 3, 5, 23
backslash (\), 21                  edit (e) command, 5, 9, 14
buffer, 3                          editing commands:
caret (^), 10, 20                    append (a), 6, 7, 9
change (c) command, 18               change (c), 18
command mode, 5-6                    copy (co), 15
``Command not found'' (message), 6   delete (d), 15-16
context search, 10-12, 19-21         edit (text editor), 3, 5, 23
control characters (`^' notation), 10edit (e), 5, 9, 14
control-H, 7                         file (f), 21-22
copy (co) command, 15                global (g), 19
corrections, 7, 16                   move (m), 14-15
current filename, 21                 number (nu), 11
current line (.), 11, 17             preserve (pre), 22-23
delete (d) command, 15-16            print (p), 10
dial-up, 5                           quit (q), 8, 13

USD:11-34                                          Ex: A Tutorial

  read (r), 22 recover  (rec),     searching, 10-12, 19-21 shell,
  22,  23  substitute (s), 11-     21 shell escape (!), 21  slash
  12, 19, 20 undo (u),  16-17,     (/), 11-12, 20 special charac-
  23  write (w), 8, 13, 21, 22     ters (^, $, \),  10,  11,  17,
  z, 12-13 !  (shell  escape),     20-21  substitute (s) command,
  21  $=,  17  +, 17 -, 17 //,     11-12, 19, 20  terminals,  4-5
  12, 20 ??, 20 ., 11, 17  .=,     text  input  mode,  7 undo (u)
  11, 17                           command,  16-17,  23  UNIX,  3
entering text, 3, 6-7 erasing      write  (w) command, 8, 13, 21,
  characters  (^H),  7   lines     22 z command, 12-13
  (@), 7
error corrections,  7,  16  ex
(text editor), 23 Ex Reference
Manual, 23 exclamation (!), 21
file,  3 file (f) command, 21-
22   file   recovery,    22-23
filename,  3,  21  global  (g)
command, 19  input  mode,  6-7
Interrupt  (message),  9  line
numbers, see also current line
  dollar sign ($), 10, 11,  17
  dot  (.), 11, 17 relative (+
  and -), 17
list, 10 logging in, 4-6  log-
ging     out,     8    ``Login
incorrect'' (message), 5 minus
(-),  17 move (m) command, 14-
15  ``Negative   address-first
buffer  line is 1'' (message),
18  ``No  current   filename''
(message), 8 ``No such file or
directory''  (message),  5,  6
``No write since last change''
(message),   21   non-printing
characters,    10    ``Nonzero
address required''  (message),
18  ``Not  an editor command''
(message), 6 ``Not  that  many
lines  in  buffer'' (message),
18  number  (nu)  command,  11
options, 22 password, 5 period
(.),  11,  17  plus  (+),   17
preserve  (pre) command, 22-23
print (p) command, 10 program,
3 prompts
  % (UNIX), 5 : (edit), 5,  6,
  7   (append), 7
question (?), 20 quit (q) com-
mand,  8, 13 read (r) command,
22 recover (rec) command,  22,
23 recovery, see file recovery
references, 3, 23 remove  (rm)
command,  21,  22 reverse com-
mand effects (undo), 16-17, 23

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung