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