xref: /original-bsd/bin/ed/USD.doc/tutorial/e1 (revision c3e32dec)
%sccs.include.proprietary.roff%

@(#)e1 8.1 (Berkeley) 06/08/93

.nr PS 9 .nr VS 11
Introduction

.ul Ed is a ``text editor'', that is, an interactive program for creating and modifying ``text'', using directions provided by a user at a terminal. The text is often a document like this one, or a program or perhaps data for a program.

This introduction is meant to simplify learning .ul ed. The recommended way to learn .ul ed is to read this document, simultaneously using .ul ed to follow the examples, then to read the description in section I of the .ul C UNIX .ul Programmer's Manual, all the while experimenting with .ul ed. (Solicitation of advice from experienced users is also useful.)

Do the exercises! They cover material not completely discussed in the actual text. An appendix summarizes the commands.

Disclaimer

This is an introduction and a tutorial. For this reason, no attempt is made to cover more than a part of the facilities that .ul ed offers (although this fraction includes the most useful and frequently used parts). When you have mastered the Tutorial, try .ul Advanced Editing on .ul C UNIX . Also, there is not enough space to explain basic C UNIX procedures. We will assume that you know how to log on to C UNIX , and that you have at least a vague understanding of what a file is. For more on that, read .ul C UNIX .ul for Beginners.

You must also know what character to type as the end-of-line on your particular terminal. This character is the C RETURN key on most terminals. Throughout, we will refer to this character, whatever it is, as C RETURN .

Getting Started

We'll assume that you have logged in to your system and it has just printed the prompt character, usually either a $ or a % . The easiest way to get .ul ed is to type

1 ed (followed by a return)

2 You are now ready to go - .ul ed is waiting for you to tell it what to do.

Creating Text - the Append command ``a''

As your first problem, suppose you want to create some text starting from scratch. Perhaps you are typing the very first draft of a paper; clearly it will have to start somewhere, and undergo modifications later. This section will show how to get some text in, just to get started. Later we'll talk about how to change it.

When .ul ed is first started, it is rather like working with a blank piece of paper - there is no text or information present. This must be supplied by the person using .ul ed; it is usually done by typing in the text, or by reading it into .ul ed from a file. We will start by typing in some text, and return shortly to how to read files.

First a bit of terminology. In .ul ed jargon, the text being worked on is said to be ``kept in a buffer.'' Think of the buffer as a work space, if you like, or simply as the information that you are going to be editing. In effect the buffer is like the piece of paper, on which we will write things, then change some of them, and finally file the whole thing away for another day.

The user tells .ul ed what to do to his text by typing instructions called ``commands.'' Most commands consist of a single letter, which must be typed in lower case. Each command is typed on a separate line. (Sometimes the command is preceded by information about what line or lines of text are to be affected - we will discuss these shortly.) .ul Ed makes no response to most commands - there is no prompting or typing of messages like ``ready''. (This silence is preferred by experienced users, but sometimes a hangup for beginners.)

The first command is .ul append, written as the letter

1 a

2 all by itself. It means ``append (or add) text lines to the buffer, as I type them in.'' Appending is rather like writing fresh material on a piece of paper.

So to enter lines of text into the buffer, just type an a followed by a C RETURN , followed by the lines of text you want, like this:

1 a Now is the time for all good men to come to the aid of their party. \*.

2

The only way to stop appending is to type a line that contains only a period. The ``\*.'' is used to tell .ul ed that you have finished appending. (Even experienced users forget that terminating ``\*.'' sometimes. If .ul ed seems to be ignoring you, type an extra line with just ``\*.'' on it. You may then find you've added some garbage lines to your text, which you'll have to take out later.)

After the append command has been done, the buffer will contain the three lines

1 Now is the time for all good men to come to the aid of their party.

2 The a '' `` and ``\*.'' aren't there, because they are not text.

To add more text to what you already have, just issue another a command, and continue typing.

Error Messages - ``?''

If at any time you make an error in the commands you type to .ul ed, it will tell you by typing

1 ?

2 This is about as cryptic as it can be, but with practice, you can usually figure out how you goofed.