home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / docs / USD.doc / edit / edittut.ms < prev    next >
Text File  |  1996-08-18  |  65KB  |  2,281 lines

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