Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / nvi / docs / USD.doc / edit / edittut.ms
1 .\" Copyright (c) 1980, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)edittut.ms  8.3 (Berkeley) 8/18/96
33 .\"
34 .ll 6.5i
35 .nr LL 6.5i
36 .EH 'USD:11-%''Edit:  A Tutorial'
37 .OH 'Edit:  A Tutorial''USD:11-%'
38 .LP
39 .ds u \s-2UNIX\s0
40 .ND
41 .sp 4
42 .ce
43 \f3\s+2Edit:  A Tutorial\s0\f1
44 .sp
45 .ce 3
46 .I
47 Ricki Blau
48 .sp
49 James Joyce
50 .R
51 .sp
52 .ce 3
53 Computing Services
54 University of California
55 Berkeley, California 94720
56 .sp 3
57 .ce
58 .I
59 ABSTRACT
60 .R
61 .sp
62 .LP
63 This narrative introduction to the use of the text editor
64 .I edit
65 assumes no prior familiarity with computers or with text editing.
66 Its aim is to lead the beginning \s-2UNIX\(dg\s+2 user through the
67 .FS
68 \(dgUNIX is a trademark of Bell Laboratories.
69 .FE
70 fundamental steps of writing and revising a file of text.
71 Edit,
72 a version of the text editor
73 .I ex,
74 was designed to provide an informative environment
75 for new and casual users.
76 .PP
77 We welcome comments and suggestions about this tutorial
78 and the \s-2UNIX\s+2 documentation in general.
79 .sp .5v
80 September 1981
81 .bp
82 .ll 6.5i
83 .nr LL 6.5i
84 .nr LT 6.5i
85 .ds u \s-2UNIX\s0
86 .ce
87 \s+2\f3Contents\f1\s0
88 .LP
89 .nf
90 Introduction\ \ \ 3
91 .sp
92 Session 1\ \ 4
93 .in +.5i
94 Making contact with \s-2UNIX\s+2\ \ \ 4
95 Logging in\ \ 4
96 Asking for \fIedit\fR\ \ \ 4
97 The ``Command not found'' message\ \ \ 5
98 A summary\ \ 5
99 Entering text\ \ \ 5
100 Messages from \fIedit\fR\ \ \ 5
101 Text input mode\ \ \ 6
102 Making corrections\ \ \ 6
103 Writing text to disk\ \ \ 7
104 Signing off\ \ 7
105 .in -.5i
106 .sp
107 Session 2\ \ \ 8
108 .in +.5i
109 Adding more text to the file\ \ \ 8
110 Interrupt\ \ \ 8
111 Making corrections\ \ \ 8
112 Listing what's in the buffer (p)\ \ \ 9
113 Finding things in the buffer\ \ \ 9
114 The current line\ \ \ 10
115 Numbering lines (nu)\ \ \ 10
116 Substitute command (s)\ \ \ 10
117 Another way to list what's in the buffer (z)\ \ \ 11
118 Saving the modified text\ \ \ 12
119 .in -.5i
120 .sp
121 Session 3\ \ \ 13
122 .in +.5i
123 Bringing text into the buffer (e)\ \ \ 13
124 Moving text in the buffer (m)\ \ \ 13
125 Copying lines (copy)\ \ \ 14
126 Deleting lines (d)\ \ \ 14
127 A word or two of caution\ \ \ 15
128 Undo (u) to the rescue\ \ \ 15
129 More about the dot (.) and buffer end ($)\ \ \ 16
130 Moving around in the buffer (+ and \-)\ \ \ 16
131 Changing lines (c)\ \ \ 17
132 .in -.5i
133 .sp
134 Session 4\ \ \ 18
135 .in +.5i
136 Making commands global (g)\ \ \ 18
137 More about searching and substituting\ \ \ 19
138 Special characters\ \ \ 19
139 Issuing \s-2UNIX\s+2 commands from the editor\ \ \ 20
140 Filenames and file manipulation\ \ \ 20
141 The file (f) command\ \ \ 20
142 Reading additional files (r)\ \ \ 21
143 Writing parts of the buffer\ \ \ 21
144 Recovering files\ \ \ 21
145 Other recovery techniques\ \ \ 21
146 Further reading and other information\ \ \ 22
147 Using \fIex\fR\ \ \ 22
148 .in -.5i
149 .sp
150 Index\ \ \ 23
151 .bp
152 .SH
153 .ce
154 \s+2Introduction\s0
155 .PP
156 Text editing using a terminal connected to a computer
157 allows you to create, modify, and print text
158 easily.
159 A
160 .I
161 text editor
162 .R
163 is a program
164 that assists you
165 as you create and modify text.
166 The text editor you will learn here is named
167 .I edit.
168 Creating text using edit is as easy as typing it
169 on an electric typewriter.
170 Modifying text involves telling the text editor 
171 what you want to add, change, or delete.
172 You can review your text
173 by typing a command
174 to print the file contents
175 as they are currently.
176 Another program (which we do not discuss in this
177 document), a text formatter,
178 rearranges your text
179 for you into ``finished form.''
180 .PP
181 These lessons assume no prior familiarity with computers
182 or with text editing.
183 They consist of a series of text editing sessions
184 which lead you through the fundamental steps
185 of creating and revising text.
186 After scanning each lesson and before beginning the next,
187 you should try the examples at a terminal to get a feeling
188 for the actual process of text editing.
189 If you set aside some time for experimentation,
190 you will soon become familiar with using the
191 computer to write and modify text.
192 In addition to the actual use of the text editor,
193 other features of \s-2UNIX\s0 will be very important to your work.
194 You can begin to
195 learn about these other features by
196 reading one of the other tutorials
197 that provide a general introduction to the system.
198 You will be ready to proceed with this lesson as soon as
199 you are familiar with (1) your terminal and its special keys,
200 (2) how to login,
201 (3) and the ways of correcting typing errors.
202 Let's first define some terms:
203 .sp .5
204 .IP program 12
205 A set of instructions, given to the computer,
206 describing the sequence of steps the computer performs
207 in order to accomplish a specific task.
208 The task must be specific,
209 such as balancing your checkbook
210 or editing your text.
211 A general task,
212 such as working for world peace,
213 is something we can all do,
214 but not something we can currently write programs to do.
215 .IP UNIX
216 \s-2UNIX\s0 is a special type of program,
217 called an operating system, that supervises the machinery
218 and all other programs comprising the total
219 computer system.
220 .IP edit
221 .I edit
222 is the name of the \s-2UNIX\s0 text editor you will be learning to use,
223 and is a program that aids you in writing or revising text.
224 Edit was designed for beginning users,
225 and is a simplified version of an editor named
226 .I ex.
227 .IP file
228 Each \s-2UNIX\s0 account is allotted
229 space for the permanent storage of information,
230 such as programs, data or text.
231 A file is a logical unit of data,
232 for example, an essay, a program,
233 or a chapter from a book,
234 which is stored on a computer system.
235 Once you create a file,
236 it is kept until you instruct the system to remove it.
237 You may create a file during one \s-2UNIX\s0 session,
238 end the session,
239 and return to use it at a later time.
240 Files contain anything you choose to write and store in them.
241 The sizes of files vary to suit your needs;
242 one file might hold only a single number,
243 yet another might contain
244 a very long document or program.
245 The only way to save
246 information from one session to the next is to store it in a file,
247 which you will learn in Session 1.
248 .IP filename
249 Filenames are used to distinguish one file from another,
250 serving the same purpose as the labels of manila
251 folders in a file cabinet.
252 In order to write or access information in a file,
253 you use the name of that file in a \s-2UNIX\s0 command,
254 and the system will automatically locate the file.
255 .IP disk
256 Files are stored on an input/output device called a disk,
257 which looks something like a stack of phonograph records.
258 Each surface is coated with a material similar to that
259 on magnetic recording tape,
260 and information is recorded on it.
261 .IP buffer
262 A temporary work space, made available to the user
263 for the duration of a session of text editing
264 and used for creating and modifying
265 the text file.
266 We can think of the buffer as a blackboard that is
267 erased after each class, where each session with the editor
268 is a class.
269 .bp
270 .SH
271 .ce 1
272 \s+2Session 1\s0
273 .sp 1
274 .SH
275 Making contact with \s-1UNIX\s0
276 .PP
277 To use the editor you must first make contact with the computer
278 by logging in to \s-2UNIX\s0.
279 We'll quickly review the standard \s-2UNIX\s0 login procedure
280 for the two ways you can make contact:
281 on a terminal that is directly linked to the computer,
282 or over a telephone line where the computer answers your call.
283 .SH
284 Directly-linked terminals
285 .PP
286 Turn on your terminal and press the \s-1RETURN\s0 key.
287 You are now ready to login.
288 .SH
289 Dial-up terminals
290 .PP
291 If your terminal connects with the computer over a telephone line,
292 turn on the terminal, dial the system access number,
293 and, when you hear a high-pitched tone, place the 
294 telephone handset in the acoustic coupler, if you are using one.
295 You are now ready to login.
296 .SH
297 Logging in
298 .PP
299 The message inviting you to login is:
300 .DS I 1i
301 login:
302 .DE
303 .LP
304 Type your login name, which identifies you to \s-2UNIX\s0,
305 on the same line as the login message,
306 and press \s-2RETURN\s+2.
307 If the terminal you are using
308 has both upper and lower case,
309 .B
310 be sure you enter your login name in lower case;
311 .R
312 otherwise \s-2UNIX\s0 assumes your terminal
313 has only upper case and will not recognize lower case
314 letters you may type.
315 \s-2UNIX\s0 types ``login:'' and you reply
316 with your login name, for example ``susan'':
317 .DS I 1i
318 login: \fBsusan\fR \fI(and press the \s-2RETURN\s0 key)\fR
319 .DE
320 (In the examples, input you would type appears in
321 .B "bold face"
322 to distinguish it from the responses from \s-2UNIX\s0.)
323 .PP
324 \s-2UNIX\s0 will next respond with a request for a password
325 as an additional precaution to prevent
326 unauthorized people from using your account.
327 The password will not appear when you type it,
328 to prevent others from seeing it.
329 The message is:
330 .DS I 1i
331 Password:    \fI(type your password and press \s-2RETURN\s+2)\fR
332 .DE
333 If any of the information you gave during the login
334 sequence was mistyped or incorrect,
335 \s-2UNIX\s0 will respond with
336 .DS I 1i
337 Login incorrect.
338 .if t .sp .2v
339 .if n .sp 1
340 login:
341 .DE
342 in which case you should start the login process anew.
343 Assuming that you have successfully
344 logged in, \s-2UNIX\s0
345 will print the message of the day and eventually will present
346 you with a % at the beginning of a fresh line.
347 The % is the \s-2UNIX\s0 prompt symbol
348 which tells you that \s-2UNIX\s0 is ready to accept a command.
349 .bd I 3
350 .SH
351 Asking for \fIedit\fP
352 .fl
353 .bd I
354 .PP
355 You are ready to tell \s-2UNIX\s0 that you
356 want to work with edit, the text editor.
357 Now is a convenient time to choose
358 a name for the file of text you are about to create.
359 To begin your editing session,
360 type
361 .B edit
362 followed by a space and then the filename
363 you have selected; for example, ``text''.
364 After that,
365 press the \s-2RETURN\s0 key and wait for edit's response:
366 .DS I 1i
367 % \fBedit text\fP    \fI(followed by a \s-2RETURN\s+2)\fR
368 "text" No such file or directory
369 :
370 .DE
371 If you typed the command correctly,
372 you will now be in communication with edit.
373 Edit has set aside a buffer for use as
374 a temporary working space during your current editing session.
375 Since ``text'' is a new file we are about to create
376 the editor was unable to find that file, which it
377 confirms by saying:
378 .DS I 1i
379 "text" No such file or directory
380 .DE
381 On the next line appears edit's prompt ``:'',
382 announcing that you are in \f2command mode\f1 and
383 edit expects a command from you.
384 You may now begin to create the new file.
385 .SH
386 The ``Command not found'' message
387 .PP
388 If you misspelled edit by typing, say, ``editor'',
389 this might appear:
390 .DS I 1i
391 % \fBeditor\fP
392 editor: Command not found
393 %
394 .DE
395 Your mistake in calling edit ``editor'' was
396 treated by \s-2UNIX\s0 as a request
397 for a program named ``editor''.
398 Since there is no program
399 named ``editor'',
400 \s-2UNIX\s0 reported that the program was ``not found''.
401 A new % indicates that \s-2UNIX\s0 is ready for another command,
402 and you may then enter the correct command.
403 .SH
404 A summary
405 .PP
406 Your exchange with \s-2UNIX\s0 as you logged in and made contact with edit
407 should look something like this:
408 .DS I 1i
409 login: \fBsusan\fP
410 Password:
411 \&... A Message of General Interest ...
412 % \fBedit text\fP
413 "text" No such file or directory
414 :
415 .DE
416 .SH
417 Entering text
418 .PP
419 You may now begin entering text into the buffer.
420 This is done by \fIappending\fP (or adding) text to whatever
421 is currently in the buffer.
422 Since there is nothing in the buffer at the moment,
423 you are appending text to nothing;
424 in effect, 
425 since you are adding text to nothing
426 you are creating text.
427 Most edit commands have two equivalent forms:
428 a word that suggests what the command does,
429 and a shorter abbreviation of that word.
430 Many beginners find the full command names
431 easier to remember at first,
432 but once you are familiar with editing you may
433 prefer to type the shorter abbreviations.
434 The command to input text is ``append''.
435 (It may be abbreviated ``a''.)
436 Type
437 .B append
438 and press the \s-2RETURN\s0 key.
439 .DS I 1i
440 % \fBedit text
441 \fR:\|\fBappend
442 .R
443 .DE
444 .SH
445 .bd I 3
446 Messages from
447 .I edit
448 .fl
449 .bd I
450 .PP
451 If you make a mistake in entering a command and
452 type something that edit does not recognize,
453 edit will respond with a message
454 intended to help you diagnose your error.
455 For example, if you misspell the command to input text by typing,
456 perhaps, ``add'' instead of ``append'' or ``a'',
457 you will receive this message:
458 .DS I 1i
459 :\|\fBadd\fR
460 add: Not an editor command
461 :
462 .DE
463 When you receive a diagnostic message,
464 check what you typed in order to determine what
465 part of your command confused edit.
466 The message above means that edit
467 was unable to recognize your mistyped command
468 and, therefore, did not execute it.
469 Instead, a new ``:''
470 appeared to let you know that
471 edit is again ready to execute a command.
472 .SH
473 Text input mode
474 .PP
475 By giving the command ``append'' (or using the abbreviation ``a''),
476 you entered
477 .I
478 text input mode,
479 .R
480 also known as
481 .I
482 append mode.
483 .R
484 When you enter text input mode,
485 edit stops sending you a prompt.
486 You will not receive any prompts
487 or error messages
488 while in text input mode.
489 You can enter
490 pretty much anything you want on the lines.
491 The lines are transmitted one by one to the buffer
492 and held there during the editing session.
493 You may append as much text as you want, and
494 .I
495 when you wish to stop entering text lines you should
496 type a period as the only character on the line
497 and press the \s-2RETURN\s0 key.
498 .R
499 When you type the period and press \s-2RETURN\s0,
500 you signal that you want to stop appending text,
501 and edit responds by allowing
502 you to exit text input mode and reenter command mode.
503 Edit will again
504 prompt you for a command by printing ``:''.
505 .PP
506 Leaving append mode does not destroy the text in
507 the buffer.
508 You have to leave append
509 mode to do any of the other kinds of editing,
510 such as changing, adding, or printing text.
511 If you type a period as the first character and
512 type any other character on the same line,
513 edit will believe you want to remain in append mode
514 and will not let you out.
515 As this can be very frustrating, 
516 be sure to type
517 .B only
518 the period and the \s-2RETURN\s0 key.
519 .PP
520 This is a good place to learn an important
521 lesson about computers and text:  a blank space is
522 a character as far as a computer is concerned.  
523 If you so much as type a period followed by a blank
524 (that is, type a period and then the space bar on the keyboard),
525 you will remain in append mode with the last line of text
526 being:
527 .DS I 1i
528 .B
529 .ps +2
530 \&.
531 .ps -2
532 .R
533 .DE
534 Let's say that you enter the lines 
535 (try to type
536 .B exactly
537 what you see, including ``thiss''):
538 .DS I 1i
539 .B
540 This is some sample text.
541 And thiss is some more text.
542 Text editing is strange, but nice.
543 \&.
544 .R
545 .DE
546 The last line is the period followed by a \s-2RETURN\s0
547 that gets you out of append mode.  
548 .SH
549 Making corrections
550 .PP
551 If you have read a general introduction to \s-2UNIX\s0,
552 you will recall that it is possible to erase individual
553 letters that you have typed.
554 This is done by typing the designated erase character
555 as many times as there are characters
556 you want to erase.
557 .PP
558 The usual erase character varies from place to place and 
559 user to user.  Often it
560 is the backspace (control-H),
561 so you can correct typing errors
562 in the line you are typing
563 by holding down the \s-1CTRL\s+1 key
564 and typing the ``H'' key.  (Sometimes it is the DEL key.)
565 If you type the erase character
566 you will notice
567 that the terminal backspaces in the line you are on.
568 You can backspace over your error,
569 and then type what you want to be the rest of the line.
570 .PP
571 If you make a bad start
572 in a line
573 and would like to begin again,
574 you can either backspace to the beginning of the line
575 or you can use the at-sign ``@'' to erase everything on the line:
576 .DS I 1i
577 .B
578 Text edtiing is strange, but@
579 Text editing is strange, but nice.
580 .R
581 .fl
582 .bd S
583 .DE
584 When you type the at-sign (@), you erase
585 the entire line typed so far
586 and are given a fresh line to type on.
587 You may immediately begin to retype the line.
588 This, unfortunately, does not work after you type the
589 line and press \s-2RETURN\s+2.  
590 To make corrections in lines that have been completed,
591 it is necessary to use the editing commands
592 covered in the next sessions.
593 .SH
594 Writing text to disk
595 .PP
596 You are now ready to edit the text.  One common operation
597 is to write the text to disk as a file for safekeeping
598 after the session is over.
599 This is the only way to save information from one session to the next,
600 since the editor's buffer is temporary and will last only until the
601 end of the editing session.
602 Learning how to write a file to disk is second in
603 importance only to entering the text.
604 To write the contents of the buffer to a disk
605 file, use the command ``write''
606 (or its abbreviation ``w''):
607 .DS I 1i
608 :\|\fBwrite
609 .R
610 .DE
611 Edit will copy the contents of the buffer to a disk file.
612 If the file does not yet exist,
613 a new file will be created automatically
614 and the presence of a ``[New file]'' will be noted.
615 The newly-created file will be given the name specified when
616 you entered the editor, in this case ``text''.
617 To confirm that the disk file has been successfully written,
618 edit will repeat the filename and give
619 the number of lines and the total
620 number of characters in the file.
621 The buffer remains unchanged by the ``write'' command.
622 All of the lines that were written to disk will still be
623 in the buffer,
624 should you want to modify or add to them.
625 .PP
626 Edit must have a name for the file to be written.
627 If you forgot to indicate the name of the file
628 when you began to edit,
629 edit will print in response to your write command:
630 .DS I 1i
631 No current filename
632 .DE
633 If this happens, you can specify the filename in a new write command:
634 .DS I 1i
635 :\|\fBwrite text
636 .R
637 .DE
638 After the ``write'' (or ``w''), type a space and then the name of the file.
639 .SH
640 Signing off
641 .PP
642 We have done enough for this first lesson on using the
643 \s-2UNIX\s0 text editor, and are ready to quit the session with edit.
644 To do this we type ``quit'' (or ``q'') and press \s-2RETURN\s+2:
645 .DS I 1i
646 :\|\fBwrite
647 .R
648 "text" [New file]  3 lines, 90 characters
649 :\|\fBquit\fR
650 %
651 .DE
652 The % is from \s-2UNIX\s0 to tell you that your session with edit is
653 over and you may command \s-2UNIX\s0 further.
654 Since we want
655 to end the entire session at the terminal, we also need to
656 exit from \s-2UNIX\s0.
657 In response to the \s-2UNIX\s0 prompt of ``\|%\|''
658 type the command
659 .DS I 1i
660 %\|\fBlogout\fR
661 .DE
662 This will end your session with \s-2UNIX\s0, and will ready the
663 terminal for the next user.
664 It is always important to type \fBlogout\fR at the end of a session
665 to make absolutely sure no one
666 could accidentally stumble into your abandoned 
667 session and thus gain access to your files,
668 tempting even the most honest of souls.
669 .sp 1
670 .PP
671 This is the end of the first session on \s-2UNIX\s0 text editing.
672 .bp
673 .TL
674 Session 2
675 .sp
676 .PP
677 Login with \s-2UNIX\s0 as in the first session:
678 .DS I 1i
679 login: \fBsusan\fP  \fI(carriage return)\fR
680 Password:       \fI(give password and carriage return)\fR
681 .if t .sp .2v
682 .if n .sp 1
683 \&... A Message of General Interest ...
684
685 .DE
686 When you indicate you want to edit,
687 you can specify the name of the file you worked on last time.
688 This will
689 start edit working, and it will fetch the contents of the
690 file into the buffer, so that you can resume editing the same file.
691 When edit has copied the file into the buffer, it
692 will repeat its name and tell
693 you the number of lines and characters it contains.
694 Thus,
695 .DS I 1i
696 .B
697 % edit text
698 .R
699 "text" 3 lines, 90 characters
700 :
701 .DE
702 means you asked edit to fetch
703 the file named ``text'' for editing,
704 causing it to copy the
705 90 characters of text into the buffer.
706 Edit awaits
707 your further instructions,
708 and indicates this by its prompt character, the colon (:).
709 In this session, we will append more text to our file,
710 print the contents of the buffer, and learn to change the text of a line.
711 .SH
712 Adding more text to the file
713 .PP
714 If you want to add more to the end of your
715 text you may do so by using the append command to enter text input mode.
716 When ``append'' is the first command
717 of your editing session,
718 the lines you enter
719 are placed at the end of the buffer.
720 Here we'll use the abbreviation for the append command, ``a'':
721 .DS I 1i
722 :\|\fBa
723 This is text added in Session 2.
724 It doesn't mean much here, but
725 it does illustrate the editor.
726 \|\fB\s+2\&.\s-2
727 .R
728 .DE
729 You may recall that once you enter append mode
730 using the ``a'' (or ``append'') command,
731 you need to type a line containing only a period (.)
732 to exit append mode.
733 .SH
734 Interrupt
735 .PP
736 Should you press the \s-2RUB\s+2 key (sometimes labelled \s-2DELETE\s+2)
737 while working with edit,
738 it will send this message to you:
739 .DS I 1i
740 Interrupt
741 :
742 .DE
743 Any command that edit might be executing
744 is terminated by rub or delete,
745 causing edit to prompt you for a new command.
746 If you are appending text at the time,
747 you will exit from append mode
748 and be expected to give another command.
749 The line of text you were typing
750 when the append command was interrupted
751 will not be entered into the buffer.
752 .SH
753 Making corrections
754 .PP
755 If while typing the line you hit an incorrect key,
756 recall that
757 you may delete the incorrect character
758 or cancel the entire line of input by erasing in the usual way.
759 Refer either
760 to the last few pages of Session 1
761 if you need to review
762 the procedures for making a correction.
763 The most important idea to remember is that
764 erasing a character or cancelling a line must be done
765 before you press the \s-2RETURN\s+2 key.
766 .SH
767 Listing what's in the buffer (p)
768 .PP
769 Having appended text to what you wrote in Session 1,
770 you might want to see all the lines in the buffer.
771 To print the contents of the buffer, type the command:
772 .DS I 1i
773 :\|\fB1,$p
774 .R
775 .DE
776 The ``1''\(dg
777 .FS
778 \(dgThe numeral ``one'' is the top left-most key,
779 and should not be confused with the letter ``el''.
780 .FE
781 stands for line 1 of the buffer,
782 the ``$'' is a special symbol designating the last line
783 of the buffer,
784 and ``p'' (or \fBprint\fR) is the command to print from line 1
785 to the end of the buffer.
786 The command ``1,$p'' gives you:
787 .DS I 1i
788 This is some sample text.
789 And thiss is some more text.
790 Text editing is strange, but nice.
791 This is text added in Session 2.
792 It doesn't mean much here, but
793 it does illustrate the editor.
794 .DE
795 Occasionally, you may accidentally
796 type a character that can't be printed,
797 which can be done by striking a key
798 while the \s-2CTRL\s0 key is pressed.
799 In printing lines, edit uses a special notation to
800 show the existence of non-printing characters.
801 Suppose you had introduced the non-printing character ``control-A''
802 into the word ``illustrate''
803 by accidently pressing the \s-2CTRL\s0 key while
804 typing ``a''.
805 This can happen on many terminals
806 because the \s-2CTRL\s+2 key and the ``A'' key
807 are beside each other.
808 If your finger presses between the two keys,
809 control-A results.
810 When asked to print the contents of the buffer,
811 edit would display
812 .DS I 1i
813 it does illustr^Ate the editor.
814 .DE
815 To represent the control-A, edit shows ``^A''.
816 The sequence ``^'' followed by a capital
817 letter stands for the one character
818 entered by holding down the \s-2CTRL\s0 key and typing the letter
819 which appears after the ``^''.
820 We'll soon discuss the commands that can be used
821 to correct this typing error.
822 .PP
823 In looking over the text we see that
824 ``this'' is typed as ``thiss'' in the second line,
825 a deliberate error so we can learn to make corrections.
826 Let's correct the spelling.
827 .SH
828 Finding things in the buffer
829 .PP
830 In order to change something in the buffer we first need to
831 find it.
832 We can find ``thiss'' in the text we have
833 entered by looking at a listing
834 of the lines.
835 Physically speaking, we search the lines
836 of text looking for ``thiss'' and stop searching when
837 we have found it.
838 The way to tell edit to search for something
839 is to type it inside slash marks:
840 .DS I 1i
841 :\|\fB/thiss/
842 .R
843 .DE
844 By typing
845 .B /thiss/
846 and pressing \s-1RETURN\s0,
847 you instruct edit to search for ``thiss''.
848 If you ask edit to look for a pattern of characters
849 which it cannot find in the buffer,
850 it will respond ``Pattern not found''.
851 When edit finds
852 the characters ``thiss'', it will print the line of text
853 for your inspection:
854 .DS I 1i
855 And thiss is some more text.
856 .DE
857 Edit is now positioned in the buffer at the
858 line it just printed,
859 ready to make a change in the line.
860 .bp
861 .SH
862 The current line
863 .PP
864 Edit keeps track of the line in the buffer where it is located
865 at all times during an editing session.
866 In general, the line that has been most recently
867 printed, entered, or changed
868 is the current location in the buffer.
869 The editor is prepared to make changes
870 at the current location in the buffer,
871 unless you direct it to another location.
872 .PP
873 In particular,
874 when you bring a file into the buffer,
875 you will be located at the last line in the file,
876 where the editor left off copying the lines
877 from the file to the buffer.
878 If your first editing command is ``append'',
879 the lines you enter are added
880 to the end of the file,
881 after the current line \(em
882 the last line in the file.
883 .PP
884 You can refer to your current location in the buffer by the
885 symbol
886 period (.) usually known by the name ``dot''.
887 If you type ``.'' and carriage
888 return you will be instructing edit to print the current line:
889 .DS I 1i
890 :\|\fB\s+2\&.\s-2
891 .R
892 And thiss is some more text.
893 .DE
894 .PP
895 If you want to know the number of the current line,
896 you can type
897 .B \&.=
898 and press \s-2RETURN\s+2,
899 and edit will respond with the line number:
900 .DS I 1i
901 :\|\fB\s+2.\s-2=
902 .R
903 2
904 .DE
905 If you type the number of any line and press \s-2RETURN\s+2,
906 edit will position you at that line and
907 print its contents:
908 .DS I 1i
909 :\|\fB2
910 .R
911 And thiss is some more text.
912 .DE
913 You should experiment with these commands
914 to gain experience in using them to make changes.
915 .SH
916 Numbering lines (nu)
917 .PP
918 The
919 .B
920 number (nu)
921 .R
922 command is similar to print,
923 giving both the number and the text of each printed line.
924 To see the number and the text of the current line type
925 .DS I 1i
926 :\|\fBnu
927 .R
928 \0\0\0\0\02\0\0And thiss is some more text.
929 .DE
930 Note that the shortest abbreviation for the number command is
931 ``nu'' (and not ``n'', which is used for a different command).
932 You may specify a range of lines
933 to be listed by the number command in the same way that lines
934 are specified for print.
935 For example, \f31,$nu\f1 lists all lines in the buffer with their
936 corresponding line numbers.
937 .SH
938 Substitute command (s)
939 .PP
940 Now that you have found the misspelled word, 
941 you can change it from ``thiss'' to ``this''.
942 As far as edit is concerned,
943 changing things is a matter of
944 substituting one thing for another.
945 As
946 .I a
947 stood for
948 .I append,
949 so
950 .I s
951 stands for
952 .I substitute.
953 We will use the abbreviation ``s'' to reduce the chance
954 of mistyping the substitute command.
955 This command will instruct edit to make the change:
956 .DS I 1i
957 \f32s/thiss/this/\f1
958 .DE
959 We first indicate the line to be changed, line 2,
960 and then
961 type an ``s'' to indicate we want
962 edit to make a substitution.
963 Inside the first set of slashes
964 are the characters that we want to change,
965 followed by the characters to replace them,
966 and then a closing slash mark.
967 To summarize:
968 .DS I 1i
969 2s/ \fIwhat is to be changed\fR / \fIwhat to change it to \fR/
970 .DE
971 If edit finds an exact match of the characters to be
972 changed it will make the change
973 .B only
974 in the first occurrence of the characters.
975 If it does not find the characters
976 to be changed, it will respond:
977 .DS I 1i
978 Substitute pattern match failed
979 .DE
980 indicating that your instructions could not be carried out.
981 When edit does find the characters that you want to change,
982 it will make the substitution and automatically print
983 the changed line, so that you can check that the correct substitution
984 was made.
985 In the example,
986 .DS I 1i
987 :\|\fB2s/thiss/this/
988 .R
989 And this is some more text.
990 .DE
991 line 2 (and line 2 only) will be searched for the characters
992 ``thiss'', and when the first exact match is found, ``thiss''
993 will be changed to ``this''.
994 Strictly speaking, it was not necessary above to
995 specify  the number of the line to be changed.
996 In
997 .DS I 1i
998 :\|\fBs/thiss/this/
999 .R
1000 .DE
1001 edit will assume that we mean to change
1002 the line where we are currently located (``.'').
1003 In this case,
1004 the command without a line number would have produced the same result
1005 because we were already located
1006 at the line we wished to change.
1007 .PP
1008 For another illustration of the substitute command,
1009 let us choose the line:
1010 .DS I 1i
1011 Text editing is strange, but nice.
1012 .DE
1013 You can make this line a bit more positive
1014 by taking out the characters ``strange, but\ '' so the line 
1015 reads:
1016 .DS I 1i
1017 Text editing is nice.
1018 .DE
1019 A command that will first position edit at the desired line
1020 and then make the substitution is:
1021 .DS I 1i
1022 :\|\fB/strange/s/strange, but //
1023 .R
1024 .DE
1025 .LP
1026 What we have done here is combine our search with
1027 our substitution.
1028 Such combinations are perfectly legal,
1029 and speed up editing quite a bit
1030 once you get used to them.
1031 That is, you do not necessarily have to use
1032 line numbers to identify a line to edit.
1033 Instead, you may identify the line you want to change
1034 by asking edit to search for a specified pattern of letters
1035 that occurs in that line.
1036 The parts of the above command are:
1037 .in +1i
1038 .TS
1039 l l.
1040 \fB/strange/\fP tells edit to find the characters ``strange'' in the text
1041 \fBs\fP tells edit to make a substitution
1042 \fB/strange, but //\fP  substitutes nothing at all for the characters ``strange, but ''
1043 .TE
1044 .in -1i
1045 .PP
1046 You should note the space after ``but'' in ``/strange, but /''. 
1047 If you do not indicate that the space is to be taken out,
1048 your line will read:
1049 .DS I 1i
1050 .if t Text editing is   nice.
1051 .if n Text editing is  nice.
1052 .DE
1053 which looks a little funny   
1054 because of the extra space between ``is'' and ``nice''.
1055 Again, we realize from this that a blank space
1056 is a real character to a computer, and in editing text
1057 we need to be aware of spaces
1058 within a line just as we would be aware of an ``a'' or 
1059 a ``4''.
1060 .SH
1061 Another way to list what's in the buffer (z)
1062 .PP
1063 Although the print command is useful for looking at specific lines
1064 in the buffer,
1065 other commands may be more convenient for
1066 viewing large sections of text.
1067 You can ask to see a screen full of text at a time
1068 by using the command
1069 .B z.
1070 If you type
1071 .DS I 1i
1072 :\|\fB1z
1073 .R
1074 .DE
1075 edit will start with line 1 and continue printing lines,
1076 stopping either when the screen of
1077 your terminal is full
1078 or when the last line in the buffer has been printed.
1079 If you want to read the next segment of text, type the command
1080 .DS I 1i
1081 :\|\fBz
1082 .DE
1083 If no starting line number is given for the z command,
1084 printing will start at the ``current'' line, in this case the
1085 last line printed.
1086 Viewing lines in the buffer one screen full at a time
1087 is known as \fIpaging\fR.
1088 Paging can also be used to print
1089 a section of text on a hard-copy terminal.
1090 .SH
1091 Saving the modified text
1092 .PP
1093 This seems to be a good place to pause in our work,
1094 and so we should end the second session.
1095 If you (in haste) type ``q'' to quit the session
1096 your dialogue with edit will be:
1097 .DS I 1i
1098 :\|\fBq
1099 .R
1100 No write since last change (:quit! overrides)
1101 :
1102 .DE
1103 This is edit's warning that you have not written
1104 the modified contents of the buffer to disk.
1105 You run the risk of losing the work you did
1106 during the editing session since you typed the latest write
1107 command.
1108 Because in this lesson we have not written
1109 to disk at all, everything we have done
1110 would have been lost
1111 if edit had obeyed the \fBq\fR command.
1112 If you did not want to save the work done during
1113 this editing session, you would have to type ``q!''
1114 or (``quit!'')
1115 to confirm that you indeed wanted to end the session
1116 immediately,
1117 leaving the file as it was
1118 after the most recent ``write'' command.
1119 However,
1120 since you want to save what
1121 you have edited, you need to type:
1122 .DS I 1i
1123 :\|\fBw
1124 .R
1125 "text" 6 lines, 171 characters
1126 .DE
1127 and then follow with the commands to quit and logout:
1128 .DS I 1i
1129 :\|\fBq
1130 % \fBlogout\fR
1131 .DE
1132 and hang up the phone or turn off the terminal when
1133 \s-2UNIX\s0 asks for a name.
1134 Terminals connected to the port selector
1135 will stop after the logout command,
1136 and pressing keys on the keyboard will do nothing.
1137 .sp 1
1138 .PP
1139 This is the end of the second session on \s-2UNIX\s0 text editing.
1140 .bp
1141 .TL
1142 Session 3
1143 .SH
1144 Bringing text into the buffer (e)
1145 .PP
1146 Login to \s-2UNIX\s0 and make contact with edit.  
1147 You should try to login without
1148 looking at the notes, but if you must
1149 then by all means do.
1150 .PP
1151 Did you remember to give the name of the file
1152 you wanted to edit?
1153 That is, did you type
1154 .DS I 1i
1155 % \fBedit text\fR
1156 .DE
1157 or simply
1158 .DS I 1i
1159 % \fBedit\fR
1160 .DE
1161 Both ways get you in contact with edit, but the first way
1162 will bring a copy of the file named ``text'' into
1163 the buffer.  
1164 If you did forget to tell edit the name of your file,
1165 you can get it into the buffer by
1166 typing:
1167 .DS I 1i
1168 :\|\fBe text
1169 .R
1170 "text" 6 lines, 171 characters
1171 .DE
1172 The command
1173 .B edit,
1174 which may be abbreviated \fBe\fR,
1175 tells edit that you want
1176 to erase anything that might already be in 
1177 the buffer and bring a copy of the file ``text'' into the buffer
1178 for editing.
1179 You may also use the edit (e) command to change files in
1180 the middle of an editing session,
1181 or to give edit the name of a new file that you want to create.
1182 Because the edit command clears the buffer,
1183 you will receive a warning if you try to edit a new file without
1184 having saved a copy of the old file.
1185 This gives you a chance to write the contents of the buffer to disk
1186 before editing the next file.
1187 .SH
1188 Moving text in the buffer (m)
1189 .PP
1190 Edit allows you to move lines of text
1191 from one location in the buffer to another
1192 by means of the
1193 .B move
1194 (\fBm\fR) command.
1195 The first two examples are for illustration only,
1196 though after you have read this Session
1197 you are welcome to return to them for practice.
1198 The command
1199 .DS I 1i
1200 :\|\fB2,4m$
1201 .R
1202 .DE
1203 directs edit to move lines 2, 3, and 4
1204 to the end of the buffer ($).  
1205 The format for the move command is that you specify
1206 the first line to be moved, the last line to be moved,
1207 the move command ``m'', and the line after which
1208 the moved text is to be placed.
1209 So,
1210 .DS I 1i
1211 :\|\fB1,3m6
1212 .R
1213 .DE
1214 would instruct edit to move lines 1 through 3 (inclusive) 
1215 to a location after line 6 in the buffer.
1216 To move only one line, say, line 4,
1217 to a location in the buffer after line 5, 
1218 the command would be ``4m5''.
1219 .PP
1220 Let's move some text using the command:
1221 .DS I 1i
1222 :\|\fB5,$m1
1223 .R
1224 2 lines moved
1225 it does illustrate the editor.
1226 .DE
1227 After executing a command that moves more than one line of the buffer,
1228 edit tells how many lines were affected by the move
1229 and prints the last moved line for your inspection.
1230 If you want to see more than just the last line,
1231 you can then
1232 use the print (p), z, or number (nu) command to view more text.
1233 The buffer should now contain:
1234 .DS I 1i
1235 This is some sample text.
1236 It doesn't mean much here, but
1237 it does illustrate the editor.
1238 And this is some more text.
1239 Text editing is nice.
1240 This is text added in Session 2.
1241 .DE
1242 You can restore the original order by typing:
1243 .DS I 1i
1244 :\|\fB4,$m1
1245 .R
1246 .DE
1247 or, combining context searching and the move command:
1248 .DS I 1i
1249 :\|\fB/And this is some/,/This is text/m/This is some sample/
1250 .R
1251 .DE
1252 (Do not type both examples here!)
1253 The problem with combining context searching
1254 with the move command 
1255 is that your chance of making a typing error
1256 in such a long command is greater than
1257 if you type line numbers.
1258 .SH
1259 Copying lines (copy)
1260 .PP
1261 The
1262 .B copy
1263 command
1264 is used to make a second copy of specified lines,
1265 leaving the original lines where they were.
1266 Copy
1267 has the same format as the move command, for example:
1268 .DS I 1i
1269 :\|\fB2,5copy $
1270 .R
1271 .DE
1272 makes a copy of lines 2 through 5,
1273 placing the added lines after the buffer's end ($).
1274 Experiment with the copy command
1275 so that you can become familiar with how it works.
1276 Note that the shortest abbreviation for copy is
1277 \f3co\f1 (and
1278 not the letter ``c'', which has another meaning).
1279 .SH
1280 Deleting lines (d)
1281 .PP
1282 Suppose you want to delete 
1283 the line
1284 .DS I 1i
1285 This is text added in Session 2.
1286 .DE
1287 from the buffer.
1288 If you know the number of the line to be deleted,
1289 you can type
1290 that number followed by
1291 \fBdelete\fR or \fBd\fR.
1292 This example deletes line 4,
1293 which is ``This is text added in Session 2.''
1294 if you typed the commands
1295 suggested so far.
1296 .DS I 1i
1297 :\|\fB4d
1298 .R
1299 It doesn't mean much here, but
1300 .DE
1301 Here ``4'' is the number of the line to be deleted,
1302 and ``delete'' or ``d'' is the command to delete the line.
1303 After executing the delete command,
1304 edit prints the line that has become the current line (``.'').
1305 .PP
1306 If you do not happen to know the line number
1307 you can search for the line and then delete it using this
1308 sequence of commands:
1309 .DS I 1i
1310 :\|\fB/added in Session 2./
1311 .R
1312 This is text added in Session 2.
1313 :\|\fBd
1314 .R
1315 It doesn't mean much here, but
1316 .DE
1317 The ``/added in Session 2./''
1318 asks edit to locate and print
1319 the line containing the indicated text,
1320 starting its search at the current line
1321 and moving line by line
1322 until it finds the text.
1323 Once you are sure that you have correctly specified the line
1324 you want to delete,
1325 you can enter the delete (d) command.
1326 In this case it is not necessary to
1327 specify a line number before the ``d''.
1328 If no line number is given,
1329 edit deletes the current line (``.''),
1330 that is, the line found by our search.
1331 After the deletion, your buffer should contain:
1332 .DS I 1i
1333 This is some sample text.
1334 And this is some more text.
1335 Text editing is nice.
1336 It doesn't mean much here, but
1337 it does illustrate the editor.
1338 And this is some more text.
1339 Text editing is nice.
1340 This is text added in Session 2.
1341 It doesn't mean much here, but
1342 .DE
1343 To delete both lines 2 and 3:
1344 .DS I 1i
1345 And this is some more text.
1346 Text editing is nice.
1347 .DE
1348 you type
1349 .DS I 1i
1350 :\|\f32,3d\f1
1351 2 lines deleted
1352 .DE
1353 which specifies the range of lines from 2 to 3,
1354 and the operation on those lines \(em ``d'' for delete.
1355 If you delete more than one line
1356 you will receive a message
1357 telling you the number of lines deleted,
1358 as indicated in the example above.
1359 .PP
1360 The previous example assumes that you know the line numbers for
1361 the lines to be deleted.
1362 If you do not you might combine the search command
1363 with the delete command:
1364 .DS I 1i
1365 :\|\fB/And this is some/,/Text editing is nice./d
1366 .R
1367 .DE
1368 .SH
1369 A word or two of caution
1370 .PP
1371 In using the search function to locate lines to
1372 be deleted you should be
1373 .B
1374 absolutely sure
1375 .R
1376 the characters you give as the basis for the search
1377 will take edit to the line you want deleted.
1378 Edit will search for the first
1379 occurrence of the characters starting from where
1380 you last edited \-
1381 that is, from the line you see printed if you type dot (.).
1382 .PP
1383 A search based on too few
1384 characters may result in the wrong lines being deleted,
1385 which edit will do as easily as if you had meant it.
1386 For this reason, it is usually safer
1387 to specify the search and then delete in two separate steps,
1388 at least until you become familiar enough with using the editor
1389 that you understand how best to specify searches.
1390 For a beginner it is not a bad idea to double-check
1391 each command before pressing \s-2RETURN\s+2 to send the command on its way.
1392 .SH
1393 Undo (u) to the rescue
1394 .PP
1395 The
1396 .B
1397 undo (u)
1398 .R
1399 command has the ability to
1400 reverse the effects of the last command that changed the buffer.
1401 To undo the previous command, type
1402 ``u'' or ``undo''.
1403 Undo can rescue
1404 the contents of the buffer from many an unfortunate mistake.
1405 However, its powers are not unlimited,
1406 so it is still wise to be reasonably
1407 careful about the commands you give.
1408 .PP
1409 It is possible to undo only commands which
1410 have the power to change the buffer \(em for example,
1411 delete, append, move, copy, substitute, and even undo itself.
1412 The commands write (w) and edit (e), which interact with disk files,
1413 cannot be undone, nor can commands that do not change
1414 the buffer, such as print.
1415 Most importantly,
1416 the
1417 .B only
1418 command that can be reversed by undo
1419 is the
1420 last ``undo-able'' command you typed.
1421 You can use control-H and @ to change
1422 commands while you are typing them,
1423 and undo to reverse the effect of the commands
1424 after you have typed them and pressed \s-2RETURN\s+2.
1425 .PP
1426 To illustrate,
1427 let's issue an undo command.
1428 Recall that the last buffer-changing command we gave deleted
1429 the lines formerly numbered 2 and 3.
1430 Typing undo at this moment will reverse the effects
1431 of the deletion, causing those two lines to be
1432 replaced in the buffer.
1433 .DS I 1i
1434 :\|\fBu
1435 .R
1436 2 more lines in file after undo
1437 And this is some more text.
1438 .DE
1439 Here again, edit informs you if the command affects more
1440 than one line,
1441 and prints
1442 the text of the line which is now ``dot'' (the current line).
1443 .SH
1444 More about the dot (.) and buffer end ($)
1445 .PP
1446 The function assumed by the symbol dot depends on its context.
1447 It can be used:
1448 .IP
1449 1.  to exit from append mode; we type dot (and only a dot) on
1450 a line and press \s-2RETURN\s+2;
1451 .IP
1452 2.  to refer to the line we are at in the buffer.
1453 .LP
1454 Dot can also be combined with the equal sign to get
1455 the number of the line currently being edited:
1456 .DS I 1i
1457 :\|\fB\&.=
1458 .R
1459 .DE
1460 If we type ``\fB.\fR='' we are asking for the number of the line,
1461 and if we type ``\fB.\fR'' we are asking for the text of the line.
1462 .PP
1463 In this editing session and the last, we used the dollar
1464 sign to indicate the end of the buffer
1465 in commands such as print, copy, and move.
1466 The dollar sign as a command asks edit to print the last
1467 line in the buffer.
1468 If the dollar sign is combined with the equal sign (\f3$=\f1)
1469 edit will print the line number corresponding to the
1470 last line in the buffer.
1471 .PP
1472 ``\fB.\fR'' and ``$'', then, represent line numbers.
1473 Whenever appropriate, these symbols can be used in
1474 place of line numbers in commands.
1475 For example
1476 .DS I 1i
1477 :\|\fB\s+2.\s-2,$d
1478 .R
1479 .DE
1480 instructs edit to delete all lines from the current line (\fB.\fR)
1481 to the end of the buffer.
1482 .SH
1483 Moving around in the buffer  (+ and \-)
1484 .PP
1485 When you are editing
1486 you often want
1487 to go back and re-read a previous line.
1488 You could specify a context search for a line you want to
1489 read if you remember some of its text,
1490 but if you simply want to see what was written a few, say 3, lines
1491 ago, you can type
1492 .DS I 1i
1493 \-3p
1494 .DE
1495 This tells edit to move back to a position 3 lines
1496 before the current line (.)
1497 and print that line.
1498 You can move forward in the buffer similarly:
1499 .DS I 1i
1500 +2p
1501 .DE
1502 instructs edit to print the line that is 2
1503 ahead of your current position.
1504 .PP
1505 You may use ``+'' and ``\-'' in any command where edit
1506 accepts line numbers.
1507 Line numbers specified with ``+'' or ``\-''
1508 can be combined to print a range of lines.
1509 The command
1510 .DS I 1i
1511 :\|\fB\-1,+2copy$
1512 .R
1513 .DE
1514 makes a copy of 4 lines:  the current line, the line before it,
1515 and the two after it.
1516 The copied lines will be placed after the last line
1517 in the buffer ($),
1518 and the original lines referred to by ``\-1'' and ``+2''
1519 remain where they are.
1520 .PP
1521 Try typing only ``\-''; you will move back one line just as
1522 if you had typed ``\-1p''.
1523 Typing the command ``+'' works similarly.
1524 You might also try typing a few plus or minus signs in a row
1525 (such as ``+++'') to see edit's response.
1526 Typing \s-2RETURN\s+2 alone on a line is the equivalent
1527 of typing ``+1p''; it will move you one line ahead in the buffer
1528 and print that line.
1529 .PP
1530 If you are at the last line of the buffer and try
1531 to move further ahead, perhaps by typing a ``+'' or
1532 a carriage return alone on the line,
1533 edit will remind you that you are at the end of the buffer:
1534 .sp
1535 .nf
1536 .ti 1i
1537 At end-of-file
1538 .br
1539 or
1540 .ti 1i
1541 Not that many lines in buffer
1542 .fi
1543 .LP
1544 Similarly, if you try to move to a position before the first line,
1545 edit will print one of these messages:
1546 .sp
1547 .nf
1548 .ti 1i
1549 Nonzero address required on this command
1550 .br
1551 or
1552 .ti 1i
1553 Negative address \- first buffer line is 1
1554 .fi
1555 .LP
1556 The number associated with a buffer line is the line's ``address'',
1557 in that it can be used to locate the line.
1558 .SH
1559 Changing lines (c)
1560 .PP
1561 You can also delete certain lines and
1562 insert new text in their place.
1563 This can be accomplished easily with the
1564 .B "change (c)"
1565 command.
1566 The change command instructs edit to delete specified lines
1567 and then switch to text input mode to
1568 accept the text that will replace them.
1569 Let's say you want to change the first two lines in the buffer:
1570 .DS I 1i
1571 This is some sample text.
1572 And this is some more text.
1573 .DE
1574 to read
1575 .DS I 1i
1576 This text was created with the \s-2UNIX\s0 text editor.
1577 .DE
1578 To do so, you type:
1579 .DS I 1i
1580 :\|\fB1,2c
1581 .R
1582 2 lines changed
1583 .B
1584 This text was created with the \s-2UNIX\s0 text editor.
1585 \s+2\&.\s-2
1586 .R
1587 :
1588 .DE
1589 In the command
1590 .B 1,2c
1591 we specify that we want to change
1592 the range of lines beginning with 1 and ending with 2
1593 by giving line numbers as with the print command.
1594 These lines will be deleted.
1595 After you type \s-2RETURN\s+2 to end the change command,
1596 edit notifies you if more than one line will be changed
1597 and places you in text input mode.
1598 Any text typed on the following lines will be inserted into
1599 the position where lines were deleted by the change command.
1600 .B
1601 You will remain in text input mode until you exit in the usual way,
1602 by typing a period alone on a line.
1603 .R
1604 Note that the number of lines added to the buffer need not be
1605 the same as the number of lines deleted.
1606 .sp 1
1607 .PP
1608 This is the end of the third session on text editing with \s-2UNIX\s0.
1609 .bp
1610 .SH
1611 .ce 1
1612 \s+2Session 4\s0
1613 .sp
1614 .PP
1615 This lesson covers several topics, starting with
1616 commands that apply throughout the buffer,
1617 characters with special meanings,
1618 and how to issue \s-2UNIX\s0 commands while in the editor.
1619 The next topics deal with files:
1620 more on reading and writing,
1621 and methods of recovering files lost in a crash.
1622 The final section suggests sources of further information.
1623 .SH
1624 Making commands global (g)
1625 .PP
1626 One disadvantage to the commands we have used for
1627 searching or substituting is that if you
1628 have a number of instances of a word to change 
1629 it appears that you have to type the command 
1630 repeatedly, once for
1631 each time the change needs to be made.
1632 Edit, however, provides a way to make commands
1633 apply to the entire contents of the buffer \-
1634 the
1635 .B
1636 global (g)
1637 .R
1638 command.
1639 .PP
1640 To print all lines
1641 containing a certain sequence of characters
1642 (say, ``text'')
1643 the command is:
1644 .DS I 1i
1645 :\|\fBg/text/p
1646 .R
1647 .DE
1648 The ``g'' instructs edit to
1649 make a global search for all lines
1650 in the buffer containing the characters  ``text''.
1651 The ``p'' prints the lines found.
1652 .PP
1653 To issue a global command, start by typing a ``g'' and then a search
1654 pattern identifying
1655 the lines to be affected.
1656 Then, on the same line, type the command to be
1657 executed for the identified lines.
1658 Global substitutions are frequently useful.
1659 For example,
1660 to change all instances of the word ``text'' to the word ``material''
1661 the command would be a combination of the global search and the
1662 substitute command:
1663 .DS I 1i
1664 :\|\fBg/text/s/text/material/g
1665 .R
1666 .DE
1667 Note the ``g'' at the end of the global command,
1668 which instructs edit to change
1669 each and every instance of ``text'' to ``material''.
1670 If you do not type the ``g'' at the end of the command
1671 only the
1672 .I first
1673 instance of ``text'' \fIin each line\fR will be changed
1674 (the normal result of the substitute command).
1675 The ``g'' at the end of the command is independent of the ``g''
1676 at the beginning.
1677 You may give a command such as:
1678 .DS I 1i
1679 :\|\fB5s/text/material/g
1680 .R
1681 .DE
1682 to change every instance of ``text'' in line 5 alone.
1683 Further, neither command will change ``text'' to ``material''
1684 if ``Text'' begins with a capital rather than a lower-case
1685 .I t.
1686 .PP
1687 Edit does not automatically print the lines modified by a
1688 global command.
1689 If you want the lines to be printed, type a ``p''
1690 at the end of the global command:
1691 .DS I 1i
1692 :\|\fBg/text/s/text/material/gp
1693 .R
1694 .DE
1695 You should be careful
1696 about using the global command in combination with any other \-
1697 in essence, be sure of what you are telling edit to do
1698 to the entire buffer.
1699 For example,
1700 .DS I 1i
1701 :\|\fBg/ /d
1702 .R
1703 72 less lines in file after global
1704 .DE
1705 will delete every line containing a blank anywhere in it.
1706 This could adversely affect
1707 your document, since most lines have spaces between words
1708 and thus would be deleted.
1709 After executing the global command,
1710 edit will print a warning if the command added or deleted more than one line.
1711 Fortunately, the undo command can reverse
1712 the effects of a global command.
1713 You should experiment with the global command
1714 on a small file of text to see what it can do for you.
1715 .SH
1716 More about searching and substituting
1717 .PP
1718 In using slashes to identify a character string
1719 that we want to search for or change,
1720 we have always specified the exact characters.
1721 There is a less tedious way to
1722 repeat the same string of characters.
1723 To change ``text'' to ``texts'' we may type either
1724 .DS I 1i
1725 :\|\fB/text/s/text/texts/
1726 .R
1727 .DE
1728 as we have done in the past,
1729 or a somewhat abbreviated command:
1730 .DS I 1i
1731 :\|\fB/text/s//texts/
1732 .R
1733 .DE
1734 In this example, the characters to be changed
1735 are not specified \-
1736 there are no characters, not even a space,
1737 between the two slash marks
1738 that indicate what is to be changed.
1739 This lack of characters between the slashes
1740 is taken by the editor to mean
1741 ``use the characters we last searched for as the characters to be changed.''
1742 .PP
1743 Similarly, the last context search may be repeated
1744 by typing a pair of slashes with nothing between them:
1745 .DS I 1i
1746 :\|\fB/does/
1747 .R
1748 It doesn't mean much here, but
1749 :\|\fB//
1750 .R
1751 it does illustrate the editor.
1752 .DE
1753 (You should note that the search command found the characters ``does''
1754 in the word ``doesn't'' in the first search request.)
1755 Because no characters are specified for the second search,
1756 the editor scans the buffer for the next occurrence of the
1757 characters ``does''.
1758 .PP
1759 Edit normally searches forward through the buffer,
1760 wrapping around from the end of the buffer to the beginning,
1761 until the specified character string is found.
1762 If you want to search in the reverse direction,
1763 use question marks (?) instead of slashes
1764 to surround the characters you are searching for.
1765 .PP
1766 It is also possible
1767 to repeat the last substitution
1768 without having to retype the entire command.
1769 An ampersand (&) used as a command
1770 repeats the most recent substitute command,
1771 using the same search and replacement patterns.
1772 After altering the current line by typing
1773 .DS I 1i
1774 :\|\fBs/text/texts/
1775 .R
1776 .DE
1777 you type
1778 .DS I 1i
1779 :\|\fB/text/&
1780 .R
1781 .DE
1782 or simply
1783 .DS I 1i
1784 :\|\fB//&
1785 .R
1786 .DE
1787 to make the same change on the next line in the buffer
1788 containing the characters ``text''.
1789 .SH
1790 Special characters
1791 .PP
1792 Two characters have special meanings when
1793 used in specifying searches:  ``$'' and ``^''.
1794 ``$'' is taken by the editor to mean ``end of the line''
1795 and is used to identify strings
1796 that occur at the end of a line.
1797 .DS I 1i
1798 :\|\fBg/text.$/s//material./p
1799 .R
1800 .DE
1801 tells the editor to search for all lines ending in ``text.''
1802 (and nothing else, not even a blank space),
1803 to change each final ``text.'' to ``material.'',
1804 and print the changed lines.
1805 .PP
1806 The symbol ``^'' indicates the beginning of a line.
1807 Thus,
1808 .DS I 1i
1809 :\|\fBs/^/1. /
1810 .R
1811 .DE
1812 instructs the editor to insert ``1.'' and a space at the beginning
1813 of the current line.
1814 .PP
1815 The characters ``$'' and ``^'' have special meanings only in the context
1816 of searching.
1817 At other times, they are ordinary characters.
1818 If you ever need to search for a character that has a special meaning,
1819 you must indicate that the
1820 character is to lose temporarily
1821 its special significance by typing another special character,
1822 the backslash (\\), before it.
1823 .DS I 1i
1824 :\|\fBs/\\\\\&$/dollar/
1825 .R
1826 .DE
1827 looks for the character ``$'' in the current
1828 line and replaces it by the word ``dollar''.
1829 Were it not for the backslash, the ``$'' would have represented
1830 ``the end of the line'' in your search
1831 rather than the character ``$''.
1832 The backslash retains its special significance
1833 unless it is preceded by another backslash.
1834 .SH
1835 Issuing \s-2UNIX\s0 commands from the editor
1836 .PP
1837 After creating several files with the editor,
1838 you may want to delete files
1839 no longer useful to you or ask for a list of your files.
1840 Removing and listing files are not functions of the editor,
1841 and so they require the use of \s-2UNIX\s0 system commands
1842 (also referred to as ``shell'' commands, as
1843 ``shell'' is the name of the program that processes \s-2UNIX\s0 commands).
1844 You do not need to quit the editor to execute a \s-2UNIX\s0 command
1845 as long as you indicate that it
1846 is to be sent to the shell for execution.
1847 To use the \s-2UNIX\s0 command
1848 .B rm
1849 to remove the file named ``junk'' type:
1850 .DS I 1i
1851 :\|\fB!rm junk
1852 .R
1853 !
1854 :
1855 .DE
1856 The exclamation mark (!)
1857 indicates that the rest of the line is to be processed as a shell command.
1858 If the buffer contents have not been written since the last change,
1859 a warning will be printed before the command is executed:
1860 .DS I 1i
1861 [No write since last change]
1862 .DE
1863 The editor prints a ``!'' when the command is completed.
1864 Other tutorials describe useful features of the system,
1865 of which an editor is only one part.
1866 .SH
1867 Filenames and file manipulation
1868 .PP
1869 Throughout each editing session,
1870 edit keeps track of the name of the file being edited as the
1871 .I "current filename."
1872 Edit remembers as the current filename the name given
1873 when you entered the editor.
1874 The current filename changes whenever the edit (e) command
1875 is used to specify a new file.
1876 Once edit has recorded a current filename,
1877 it inserts that name into any command where a filename has been omitted.
1878 If a write command does not specify a file,
1879 edit, as we have seen, supplies the current filename.
1880 If you are editing a file named ``draft3'' having 283 lines in it,
1881 you can have the editor write onto a different file
1882 by including its name in the write command:
1883 .DS I 1i
1884 :\fB\|w chapter3
1885 .R
1886 "chapter3" [new file] 283 lines, 8698 characters
1887 .DE
1888 The current filename remembered by the editor
1889 .I
1890 will not be changed as a result of the write command.
1891 .R
1892 Thus, if the next write command
1893 does not specify a name,
1894 edit will write onto the current file (``draft3'')
1895 and not onto the file ``chapter3''.
1896 .SH
1897 The file (f) command
1898 .PP
1899 To ask for the current filename, type
1900 .B file
1901 (or
1902 .B f ).
1903 In response, the editor provides current information about the buffer,
1904 including the filename, your current position, the number of
1905 lines in the buffer,
1906 and the percent of the distance through the file
1907 your current location is.
1908 .DS I 1i
1909 :\|\fBf
1910 .R
1911 "text" [Modified] line 3 of 4 --75%--
1912 .DE
1913 .\"The expression ``[Edited]'' indicates that the buffer contains
1914 .\"either the editor's copy of the existing file ``text''
1915 .\"or a file which you are just now creating.
1916 If the contents of the buffer have changed
1917 since the last time the file was written,
1918 the editor will tell you that the file has been ``[Modified]''.
1919 After you save the changes by writing onto a disk file,
1920 the buffer will no longer be considered modified:
1921 .DS I 1i
1922 :\|\fBw
1923 .R
1924 "text" 4 lines, 88 characters
1925 :\|\fBf
1926 .R
1927 "text" line 3 of 4 --75%--
1928 .DE
1929 .SH
1930 Reading additional files (r)
1931 .PP
1932 The
1933 \f3read (r)\f1 command allows you to add the contents of a file
1934 to the buffer
1935 at a specified location,
1936 essentially copying new lines
1937 between two existing lines.
1938 To use it, specify the line after which the new text will be placed,
1939 the \f3read (r)\f1 command,
1940 and then the name of the file.
1941 If you have a file named ``example'', the command
1942 .DS I 1i
1943 :\|\fB$r example
1944 .R
1945 "example" 18 lines, 473 characters
1946 .DE
1947 reads the file ``example''
1948 and adds it to the buffer after the last line.
1949 The current filename is not changed by the read command.
1950 .SH
1951 Writing parts of the buffer
1952 .PP
1953 The
1954 .B
1955 write (w)
1956 .R
1957 command can write all or part of the buffer
1958 to a file you specify.
1959 We are already familiar with
1960 writing the entire contents of the
1961 buffer to a disk file.
1962 To write only part of the buffer onto a file,
1963 indicate the beginning and ending lines before the write command,
1964 for example
1965 .DS I 1i
1966 :\|\fB45,$w ending
1967 .R
1968 .DE
1969 Here all lines from 45 through the end of the buffer
1970 are written onto the file named
1971 .I ending.
1972 The lines remain in the buffer
1973 as part of the document you are editing,
1974 and you may continue to edit the entire buffer.
1975 Your original file is unaffected
1976 by your command to write part of the buffer
1977 to another file.
1978 Edit still remembers whether you have saved changes to the buffer
1979 in your original file or not.
1980 .SH
1981 Recovering files
1982 .PP
1983 Although it does not happen very often,
1984 there are times \s-2UNIX\s+2 stops working
1985 because of some malfunction.
1986 This situation is known as a \fIcrash\fR.
1987 Under most circumstances,
1988 edit's crash recovery feature
1989 is able to save work to within a few lines of changes
1990 before a crash (or an accidental phone hang up).
1991 If you lose the contents of an editing buffer in a system crash,
1992 you will normally receive mail when you login that gives
1993 the name of the recovered file.
1994 To recover the file,
1995 enter the editor and type the command
1996 .B recover
1997 (\fBrec\fR),
1998 followed by the name of the lost file.
1999 For example,
2000 to recover the buffer for an edit session
2001 involving the file ``chap6'', the command is:
2002 .DS I 1i
2003 .R
2004 :\|\fBrecover chap6
2005 .R
2006 .DE
2007 Recover is sometimes unable to save the entire buffer successfully,
2008 so always check the contents of the saved buffer carefully
2009 before writing it back onto the original file.
2010 For best results,
2011 write the buffer to a new file temporarily
2012 so you can examine it without risk to the original file.
2013 Unfortunately,
2014 you cannot use the recover command
2015 to retrieve a file you removed
2016 using the shell command \f3rm\f1.
2017 .SH
2018 Other recovery techniques
2019 .PP
2020 If something goes wrong when you are using the editor,
2021 it may be possible to save your work by using the command
2022 .B preserve
2023 (\fBpre\fR),
2024 which saves the buffer as if the system had crashed.
2025 If you are writing a file and you get the message
2026 ``Quota exceeded'', you have tried to use more disk storage
2027 than is allotted to your account.
2028 .I
2029 Proceed with caution
2030 .R
2031 because it is likely that only a part
2032 of the editor's buffer is now present in the file you tried to write.
2033 In this case you should use the shell escape from the editor (!)
2034 to remove some files you don't need and try to write
2035 the file again.
2036 If this is not possible and you cannot find someone to help you,
2037 enter the command
2038 .DS I 1i
2039 :\|\fBpreserve
2040 .R
2041 .DE
2042 and wait for the reply,
2043 .DS I 1i
2044 File preserved.
2045 .DE
2046 If you do not receive this reply,
2047 seek help immediately.
2048 Do not simply leave the editor.
2049 If you do, the buffer will be lost, 
2050 and you may not be able to save your file.
2051 If the reply is ``File preserved.''
2052 you can leave the editor
2053 (or logout)
2054 to remedy the situation.
2055 After a preserve, you can use the recover command
2056 once the problem has been corrected,
2057 or the \fB\-r\fR option of the edit command
2058 if you leave the editor and want to return.
2059 .PP
2060 If you make an undesirable change to the buffer
2061 and type a write command before discovering your mistake,
2062 the modified version will replace any previous version of the file.
2063 Should you ever lose a good version of a document in this way,
2064 do not panic and leave the editor.
2065 As long as you stay in the editor,
2066 the contents of the buffer remain accessible.
2067 Depending on the nature of the problem,
2068 it may be possible
2069 to restore the buffer to a more complete
2070 state with the undo command.
2071 After fixing the damaged buffer, you can again write the file
2072 to disk.
2073 .SH
2074 Further reading and other information
2075 .PP
2076 Edit is an editor designed for beginning and casual users.
2077 It is actually a version of a more powerful editor called
2078 .I ex.
2079 These lessons are intended to introduce you to the editor
2080 and its more commonly-used commands.
2081 We have not covered all of the editor's commands,
2082 but a selection of commands
2083 that should be sufficient to accomplish most of your editing tasks.
2084 You can find out more about the editor in the
2085 .I
2086 Ex Reference Manual,
2087 .R
2088 which is applicable to both
2089 .I ex
2090 and
2091 .I edit.
2092 One way to become familiar with the manual is to begin by reading
2093 the description of commands that you already know.
2094 .bd I 3
2095 .SH
2096 Using
2097 .I ex
2098 .fl
2099 .bd I
2100 .PP
2101 As you become more experienced with using the editor,
2102 you may still find that edit continues to meet your needs.
2103 However, should you become interested in using 
2104 .I ex,
2105 it is easy to switch.
2106 To begin an editing session with 
2107 .I ex,
2108 use the name
2109 .B ex
2110 in your command instead of
2111 .B edit.
2112 .PP
2113 Edit commands also work in 
2114 .I ex,
2115 but the editing environment is somewhat different.
2116 You should be aware of a few differences
2117 between 
2118 .I ex
2119 and 
2120 .I edit.
2121 In edit, only the characters ``^'', ``$'', and ``\\'' have
2122 special meanings in searching the buffer
2123 or indicating characters to be changed by a substitute command.
2124 Several additional characters have special
2125 meanings in ex, as described in the
2126 .I
2127 Ex Reference Manual.
2128 .R
2129 Another feature of the edit environment prevents users from
2130 accidently entering two alternative modes of editing,
2131 .I open
2132 and
2133 .I visual,
2134 in which
2135 the editor behaves quite differently from normal command mode.
2136 If you are using ex and you encounter strange behavior,
2137 you may have accidently entered open mode by typing ``o''.
2138 Type the \s-2ESC\s0 key and then a ``Q''
2139 to get out of open or visual mode and back into
2140 the regular editor command mode.
2141 The document
2142 .I
2143 An Introduction to Display Editing with Vi\|\|
2144 .R
2145 provide full details of visual mode.
2146 .bp
2147 .SH
2148 .ce 1
2149 \s+2Index\s0
2150 .LP
2151 .sp 2
2152 .2C
2153 .nf
2154 addressing, \fIsee\fR line numbers
2155 ampersand, 20
2156 append mode, 6-7
2157 append (a) command, 6, 7, 9
2158 ``At end of file'' (message), 18
2159 backslash (\\), 21
2160 buffer, 3
2161 caret (^), 10, 20
2162 change (c) command, 18
2163 command mode, 5-6
2164 ``Command not found'' (message), 6
2165 context search, 10-12, 19-21
2166 control characters (``^'' notation), 10
2167 control-H, 7
2168 copy (co) command, 15
2169 corrections, 7, 16
2170 current filename, 21
2171 current line (\|.\|), 11, 17
2172 delete (d) command, 15-16
2173 dial-up, 5
2174 disk, 3
2175 documentation, 3, 23
2176 dollar ($), 10, 11, 17, 20-21
2177 dot (\f3\|.\|\f1) 11, 17
2178 edit (text editor), 3, 5, 23
2179 edit (e) command, 5, 9, 14
2180 editing commands:
2181 .in +.25i
2182 append (a), 6, 7, 9
2183 change (c), 18
2184 copy (co), 15
2185 delete (d), 15-16
2186 edit (text editor), 3, 5, 23
2187 edit (e), 5, 9, 14
2188 file (f), 21-22
2189 global (g), 19
2190 move (m), 14-15
2191 number (nu), 11
2192 preserve (pre), 22-23
2193 print (p), 10
2194 quit (q), 8, 13
2195 read (r), 22
2196 recover (rec), 22, 23
2197 substitute (s), 11-12, 19, 20
2198 undo (u), 16-17, 23
2199 write (w), 8, 13, 21, 22
2200 z, 12-13
2201 ! (shell escape), 21
2202 $=, 17
2203 +, 17
2204 \-, 17
2205 //, 12, 20
2206 ??, 20
2207 \&., 11, 17
2208 \&.=, 11, 17
2209 .in -.25i
2210 entering text, 3, 6-7
2211 erasing
2212 .in +.25i
2213 characters (^H), 7
2214 lines (@), 7
2215 .in -.25i
2216 error corrections, 7, 16
2217 ex (text editor), 23
2218 \fIEx Reference Manual\fR, 23
2219 exclamation (!), 21
2220 file, 3
2221 file (f) command, 21-22
2222 file recovery, 22-23
2223 filename, 3, 21
2224 global (g) command, 19
2225 input mode, 6-7
2226 Interrupt (message), 9
2227 line numbers, \fIsee also\fR current line
2228 .in +.25i
2229 dollar sign ($), 10, 11, 17
2230 dot (\|.\|), 11, 17
2231 relative (+ and \-), 17
2232 .in -.25i
2233 list, 10
2234 logging in, 4-6
2235 logging out, 8
2236 ``Login incorrect'' (message), 5
2237 minus (\-), 17
2238 move (m) command, 14-15
2239 ``Negative address\(emfirst buffer line is 1'' (message), 18
2240 ``No current filename'' (message), 8
2241 ``No such file or directory'' (message), 5, 6
2242 ``No write since last change'' (message), 21
2243 non-printing characters, 10
2244 ``Nonzero address required'' (message), 18
2245 ``Not an editor command'' (message), 6
2246 ``Not that many lines in buffer'' (message), 18
2247 number (nu) command, 11
2248 password, 5
2249 period (\|.\|), 11, 17
2250 plus (+), 17
2251 preserve (pre) command, 22-23
2252 print (p) command, 10
2253 program, 3
2254 prompts
2255 .in .25i
2256 % (\s-2UNIX\s0), 5
2257 : (edit), 5, 6, 7
2258 \0 (append), 7
2259 .in -.25i
2260 question (?), 20
2261 quit (q) command, 8, 13
2262 read (r) command, 22
2263 recover (rec) command, 22, 23
2264 recovery, \fIsee\fR\| file recovery
2265 references, 3, 23
2266 remove (rm) command, 21, 22
2267 reverse command effects (undo), 16-17, 23
2268 searching, 10-12, 19-21
2269 shell, 21
2270 shell escape (!), 21
2271 slash (/), 11-12, 20
2272 special characters (^, $, \\), 10, 11, 17, 20-21
2273 substitute (s) command, 11-12, 19, 20
2274 terminals, 4-5
2275 text input mode, 7
2276 undo (u) command, 16-17, 23
2277 \s-1UNIX\s0, 3
2278 write (w) command, 8, 13, 21, 22
2279 z command, 12-13
2280