Annotation of 43BSDReno/share/doc/usd/14.edit/edittut.ms, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.