BSD 3 development
[unix-history] / usr / doc / edtut / e1
CommitLineData
8340f87c
BJ
1.nr PS 9
2.nr VS 11
3.if t .2C
4.SH
5Introduction
6.PP
7.ul
8Ed
9is a ``text editor'', that is, an interactive program
10for creating and modifying ``text'',
11using directions provided by a user at
12a terminal.
13The text is often a document
14like this one,
15or a program
16or perhaps data for a program.
17.PP
18This introduction is meant to simplify learning
19.ul
20ed.
21The recommended way to learn
22.ul
23ed
24is to read this document,
25simultaneously using
26.ul
27ed
28to follow the examples,
29then to read the description in section I of the
30.ul
31.UC UNIX
32.ul
33Programmer's Manual,
34all the while
35experimenting with
36.ul
37ed.
38(Solicitation of advice from experienced users is also useful.)
39.PP
40Do the exercises!
41They cover material not completely discussed
42in the actual text.
43An appendix summarizes the commands.
44.SH
45Disclaimer
46.PP
47This is an introduction and a tutorial.
48For this reason, no attempt is made to
49cover more than a part of the facilities that
50.ul
51ed
52offers
53(although this fraction includes the most useful and frequently used
54parts).
55When you have mastered the Tutorial,
56try
57.ul
58Advanced Editing on
59.ul
60.UC UNIX .
61Also,
62there is not enough space to explain basic
63.UC UNIX
64procedures.
65We will assume that you know how to log on to
66.UC UNIX ,
67and that you have at least a vague understanding
68of what a file is.
69For more on that, read
70.ul
71.UC UNIX
72.ul
73for Beginners.
74.PP
75You must also know what character to type as the end-of-line
76on your particular terminal.
77This character is the
78.UC RETURN
79key on most terminals.
80Throughout, we will refer to this character,
81whatever it is,
82as
83.UC RETURN .
84.SH
85Getting Started
86.PP
87We'll assume that you have logged in to
88your system
89and it has just printed the prompt character,
90usually either a
91.UL $
92or a
93.UL % .
94The
95easiest way to get
96.ul
97ed
98is to type
99.P1
100ed (followed by a return)
101.P2
102You are now ready to go \-
103.ul
104ed
105is waiting for you to tell it what to do.
106.SH
107Creating Text \- the Append command ``a''
108.PP
109As your first problem, suppose you want to create some text
110starting from scratch.
111Perhaps you are typing the very first
112draft of a paper; clearly it will have to start
113somewhere, and undergo modifications later.
114This section will show how to get some text in, just to
115get started.
116Later we'll talk about how to change it.
117.PP
118When
119.ul
120ed
121is first started, it is rather like working
122with a blank piece of paper \- there is no text
123or information present.
124This must be supplied by the person using
125.ul
126ed;
127it is usually done
128by typing in the text, or by reading it into
129.ul
130ed
131from a
132file.
133We will start by typing in some text, and return shortly to how to
134read files.
135.PP
136First a bit of terminology.
137In
138.ul
139ed
140jargon, the text being
141worked on is said to be ``kept in a buffer.''
142Think of the
143buffer as a work space, if you like, or simply as the information
144that you are going to be editing.
145In effect the buffer is like the
146piece of paper, on which we will write things, then change some
147of them, and finally file the whole thing away for another day.
148.PP
149The user tells
150.ul
151ed
152what to do to his text
153by typing instructions called ``commands.''
154Most
155commands consist of a single letter,
156which must be typed in lower case.
157Each command is typed
158on a separate line.
159(Sometimes the command is preceded by information
160about what line or lines of text are to be affected \-
161we will discuss these shortly.)
162.ul
163Ed
164makes no response
165to most commands \- there is no prompting
166or typing of messages like ``ready''.
167(This silence is preferred
168by experienced users, but sometimes a hangup for beginners.)
169.PP
170The first command is
171.ul
172append,
173written as the letter
174.P1
175a
176.P2
177all
178by itself.
179It means ``append (or add) text lines to the buffer,
180as I type them in.''
181Appending is rather like
182writing fresh material on a piece of paper.
183.PP
184So to enter lines of text into the buffer,
185just type an
186.UL a
187followed by a
188.UC RETURN ,
189followed by the lines of text you want, like this:
190.P1
191a
192Now is the time
193for all good men
194to come to the aid of their party.
195\*.
196.P2
197.PP
198The only way to stop appending is to type a
199line that contains only a period.
200The ``\*.'' is used
201to tell
202.ul
203ed
204that you have finished appending.
205(Even experienced users forget that terminating ``\*.''
206sometimes.
207If
208.ul
209ed
210seems to be ignoring you,
211type an extra line with just ``\*.'' on it.
212You may then find you've added some garbage lines
213to your text, which you'll have to take out later.)
214.PP
215After the append command has been done, the buffer will
216contain the three lines
217.P1
218Now is the time
219for all good men
220to come to the aid of their party.
221.P2
222The
223.UL a '' ``
224and ``\*.'' aren't there, because they are
225not text.
226.PP
227To add more text to what you already have,
228just issue another
229.UL a
230command, and continue typing.
231.SH
232Error Messages \- ``?''
233.PP
234If at any time you make an error in the commands you type to
235.ul
236ed,
237it will tell you by typing
238.P1
239?
240.P2
241This is about as cryptic as it can be,
242but with practice, you can usually
243figure out how you goofed.