home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / riscbsd / 1_1_contri / usd / 14_edit / edittut_ms < prev    next >
Encoding:
Text File  |  1986-05-28  |  62.6 KB  |  2,296 lines

  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. .DE
  658. When you indicate you want to edit,
  659. you can specify the name of the file you worked on last time.
  660. This will
  661. start edit working, and it will fetch the contents of the
  662. file into the buffer, so that you can resume editing the same file.
  663. When edit has copied the file into the buffer, it
  664. will repeat its name and tell
  665. you the number of lines and characters it contains.
  666. Thus,
  667. .DS I 1i
  668. .B
  669. % edit text
  670. .R
  671. "text" 3 lines, 90 characters
  672. :
  673. .DE
  674. means you asked edit to fetch
  675. the file named ``text'' for editing,
  676. causing it to copy the
  677. 90 characters of text into the buffer.
  678. Edit awaits
  679. your further instructions,
  680. and indicates this by its prompt character, the colon (:).
  681. In this session, we will append more text to our file,
  682. print the contents of the buffer, and learn to change the text of a line.
  683. .SH
  684. Adding more text to the file
  685. .PP
  686. If you want to add more to the end of your
  687. text you may do so by using the append command to enter text input mode.
  688. When ``append'' is the first command
  689. of your editing session,
  690. the lines you enter
  691. are placed at the end of the buffer.
  692. Here we'll use the abbreviation for the append command, ``a'':
  693. .DS I 1i
  694. :\|\fBa
  695. This is text added in Session 2.
  696. It doesn't mean much here, but
  697. it does illustrate the editor.
  698. \|\fB\s+2\&.\s-2
  699. .R
  700. .DE
  701. You may recall that once you enter append mode
  702. using the ``a'' (or ``append'') command,
  703. you need to type a line containing only a period (.)
  704. to exit append mode.
  705. .SH
  706. Interrupt
  707. .PP
  708. Should you press the \s-2RUB\s+2 key (sometimes labelled \s-2DELETE\s+2)
  709. while working with edit,
  710. it will send this message to you:
  711. .DS I 1i
  712. Interrupt
  713. :
  714. .DE
  715. Any command that edit might be executing
  716. is terminated by rub or delete,
  717. causing edit to prompt you for a new command.
  718. If you are appending text at the time,
  719. you will exit from append mode
  720. and be expected to give another command.
  721. The line of text you were typing
  722. when the append command was interrupted
  723. will not be entered into the buffer.
  724. .SH
  725. Making corrections
  726. .PP
  727. If while typing the line you hit an incorrect key,
  728. recall that
  729. you may delete the incorrect character
  730. or cancel the entire line of input by erasing in the usual way.
  731. Refer either
  732. to the last few pages of Session 1
  733. if you need to review
  734. the procedures for making a correction.
  735. The most important idea to remember is that
  736. erasing a character or cancelling a line must be done
  737. before you press the \s-2RETURN\s+2 key.
  738. .SH
  739. Listing what's in the buffer (p)
  740. .PP
  741. Having appended text to what you wrote in Session 1,
  742. you might want to see all the lines in the buffer.
  743. To print the contents of the buffer, type the command:
  744. .DS I 1i
  745. :\|\fB1,$p
  746. .R
  747. .DE
  748. The ``1''\(dg
  749. .FS
  750. \(dgThe numeral ``one'' is the top left-most key,
  751. and should not be confused with the letter ``el''.
  752. .FE
  753. stands for line 1 of the buffer,
  754. the ``$'' is a special symbol designating the last line
  755. of the buffer,
  756. and ``p'' (or \fBprint\fR) is the command to print from line 1
  757. to the end of the buffer.
  758. The command ``1,$p'' gives you:
  759. .DS I 1i
  760. This is some sample text.
  761. And thiss is some more text.
  762. Text editing is strange, but nice.
  763. This is text added in Session 2.
  764. It doesn't mean much here, but
  765. it does illustrate the editor.
  766. .DE
  767. Occasionally, you may accidentally
  768. type a character that can't be printed,
  769. which can be done by striking a key
  770. while the \s-2CTRL\s0 key is pressed.
  771. In printing lines, edit uses a special notation to
  772. show the existence of non-printing characters.
  773. Suppose you had introduced the non-printing character ``control-A''
  774. into the word ``illustrate''
  775. by accidently pressing the \s-2CTRL\s0 key while
  776. typing ``a''.
  777. This can happen on many terminals
  778. because the \s-2CTRL\s+2 key and the ``A'' key
  779. are beside each other.
  780. If your finger presses between the two keys,
  781. control-A results.
  782. When asked to print the contents of the buffer,
  783. edit would display
  784. .DS I 1i
  785. it does illustr^Ate the editor.
  786. .DE
  787. To represent the control-A, edit shows ``^A''.
  788. The sequence ``^'' followed by a capital
  789. letter stands for the one character
  790. entered by holding down the \s-2CTRL\s0 key and typing the letter
  791. which appears after the ``^''.
  792. We'll soon discuss the commands that can be used
  793. to correct this typing error.
  794. .PP
  795. In looking over the text we see that
  796. ``this'' is typed as ``thiss'' in the second line,
  797. a deliberate error so we can learn to make corrections.
  798. Let's correct the spelling.
  799. .SH
  800. Finding things in the buffer
  801. .PP
  802. In order to change something in the buffer we first need to
  803. find it.
  804. We can find ``thiss'' in the text we have
  805. entered by looking at a listing
  806. of the lines.
  807. Physically speaking, we search the lines
  808. of text looking for ``thiss'' and stop searching when
  809. we have found it.
  810. The way to tell edit to search for something
  811. is to type it inside slash marks:
  812. .DS I 1i
  813. :\|\fB/thiss/
  814. .R
  815. .DE
  816. By typing
  817. .B /thiss/
  818. and pressing \s-1RETURN\s0,
  819. you instruct edit to search for ``thiss''.
  820. If you ask edit to look for a pattern of characters
  821. which it cannot find in the buffer,
  822. it will respond ``Pattern not found''.
  823. When edit finds
  824. the characters ``thiss'', it will print the line of text
  825. for your inspection:
  826. .DS I 1i
  827. And thiss is some more text.
  828. .DE
  829. Edit is now positioned in the buffer at the
  830. line it just printed,
  831. ready to make a change in the line.
  832. .bp
  833. .SH
  834. The current line
  835. .PP
  836. Edit keeps track of the line in the buffer where it is located
  837. at all times during an editing session.
  838. In general, the line that has been most recently
  839. printed, entered, or changed
  840. is the current location in the buffer.
  841. The editor is prepared to make changes
  842. at the current location in the buffer,
  843. unless you direct it to another location.
  844. .PP
  845. In particular,
  846. when you bring a file into the buffer,
  847. you will be located at the last line in the file,
  848. where the editor left off copying the lines
  849. from the file to the buffer.
  850. If your first editing command is ``append'',
  851. the lines you enter are added
  852. to the end of the file,
  853. after the current line \(em
  854. the last line in the file.
  855. .PP
  856. You can refer to your current location in the buffer by the
  857. symbol
  858. period (.) usually known by the name ``dot''.
  859. If you type ``.'' and carriage
  860. return you will be instructing edit to print the current line:
  861. .DS I 1i
  862. :\|\fB\s+2\&.\s-2
  863. .R
  864. And thiss is some more text.
  865. .DE
  866. .PP
  867. If you want to know the number of the current line,
  868. you can type
  869. .B \&.=
  870. and press \s-2RETURN\s+2,
  871. and edit will respond with the line number:
  872. .DS I 1i
  873. :\|\fB\s+2.\s-2=
  874. .R
  875. 2
  876. .DE
  877. If you type the number of any line and press \s-2RETURN\s+2,
  878. edit will position you at that line and
  879. print its contents:
  880. .DS I 1i
  881. :\|\fB2
  882. .R
  883. And thiss is some more text.
  884. .DE
  885. You should experiment with these commands
  886. to gain experience in using them to make changes.
  887. .SH
  888. Numbering lines (nu)
  889. .PP
  890. The
  891. .B
  892. number (nu)
  893. .R
  894. command is similar to print,
  895. giving both the number and the text of each printed line.
  896. To see the number and the text of the current line type
  897. .DS I 1i
  898. :\|\fBnu
  899. .R
  900. \0\0\0\0\02\0\0And thiss is some more text.
  901. .DE
  902. Note that the shortest abbreviation for the number command is
  903. ``nu'' (and not ``n'', which is used for a different command).
  904. You may specify a range of lines
  905. to be listed by the number command in the same way that lines
  906. are specified for print.
  907. For example, \f31,$nu\f1 lists all lines in the buffer with their
  908. corresponding line numbers.
  909. .SH
  910. Substitute command (s)
  911. .PP
  912. Now that you have found the misspelled word, 
  913. you can change it from ``thiss'' to ``this''.
  914. As far as edit is concerned,
  915. changing things is a matter of
  916. substituting one thing for another.
  917. As
  918. .I a
  919. stood for
  920. .I append,
  921. so
  922. .I s
  923. stands for
  924. .I substitute.
  925. We will use the abbreviation ``s'' to reduce the chance
  926. of mistyping the substitute command.
  927. This command will instruct edit to make the change:
  928. .DS I 1i
  929. \f32s/thiss/this/\f1
  930. .DE
  931. We first indicate the line to be changed, line 2,
  932. and then
  933. type an ``s'' to indicate we want
  934. edit to make a substitution.
  935. Inside the first set of slashes
  936. are the characters that we want to change,
  937. followed by the characters to replace them,
  938. and then a closing slash mark.
  939. To summarize:
  940. .DS I 1i
  941. 2s/ \fIwhat is to be changed\fR / \fIwhat to change it to \fR/
  942. .DE
  943. If edit finds an exact match of the characters to be
  944. changed it will make the change
  945. .B only
  946. in the first occurrence of the characters.
  947. If it does not find the characters
  948. to be changed, it will respond:
  949. .DS I 1i
  950. Substitute pattern match failed
  951. .DE
  952. indicating that your instructions could not be carried out.
  953. When edit does find the characters that you want to change,
  954. it will make the substitution and automatically print
  955. the changed line, so that you can check that the correct substitution
  956. was made.
  957. In the example,
  958. .DS I 1i
  959. :\|\fB2s/thiss/this/
  960. .R
  961. And this is some more text.
  962. .DE
  963. line 2 (and line 2 only) will be searched for the characters
  964. ``thiss'', and when the first exact match is found, ``thiss''
  965. will be changed to ``this''.
  966. Strictly speaking, it was not necessary above to
  967. specify  the number of the line to be changed.
  968. In
  969. .DS I 1i
  970. :\|\fBs/thiss/this/
  971. .R
  972. .DE
  973. edit will assume that we mean to change
  974. the line where we are currently located (``.'').
  975. In this case,
  976. the command without a line number would have produced the same result
  977. because we were already located
  978. at the line we wished to change.
  979. .PP
  980. For another illustration of the substitute command,
  981. let us choose the line:
  982. .DS I 1i
  983. Text editing is strange, but nice.
  984. .DE
  985. You can make this line a bit more positive
  986. by taking out the characters ``strange, but\ '' so the line 
  987. reads:
  988. .DS I 1i
  989. Text editing is nice.
  990. .DE
  991. A command that will first position edit at the desired line
  992. and then make the substitution is:
  993. .DS I 1i
  994. :\|\fB/strange/s/strange, but //
  995. .R
  996. .DE
  997. .LP
  998. What we have done here is combine our search with
  999. our substitution.
  1000. Such combinations are perfectly legal,
  1001. and speed up editing quite a bit
  1002. once you get used to them.
  1003. That is, you do not necessarily have to use
  1004. line numbers to identify a line to edit.
  1005. Instead, you may identify the line you want to change
  1006. by asking edit to search for a specified pattern of letters
  1007. that occurs in that line.
  1008. The parts of the above command are:
  1009. .TS
  1010. .in +1i
  1011. .nr 35 \n(.u
  1012. .nf
  1013. .ds #d .d
  1014. .if \(ts\n(.z\(ts\(ts .ds #d nl
  1015. .nr 80 0
  1016. .nr 38 \w\f3/strange/\fP
  1017. .if \n(80<\n(38 .nr 80 \n(38
  1018. .nr 38 \w\f3s\fP
  1019. .if \n(80<\n(38 .nr 80 \n(38
  1020. .nr 38 \w\f3/strange, but //\fP
  1021. .if \n(80<\n(38 .nr 80 \n(38
  1022. .nr 81 0
  1023. .nr 38 \wtells edit to find the characters ``strange'' in the text
  1024. .if \n(81<\n(38 .nr 81 \n(38
  1025. .nr 38 \wtells edit to make a substitution
  1026. .if \n(81<\n(38 .nr 81 \n(38
  1027. .nr 38 \wsubstitutes nothing at all for the characters ``strange, but ''
  1028. .if \n(81<\n(38 .nr 81 \n(38
  1029. .nr 38 1n
  1030. .nr 79 0
  1031. .nr 40 \n(79+(0*\n(38)
  1032. .nr 80 +\n(40
  1033. .nr 41 \n(80+(3*\n(38)
  1034. .nr 81 +\n(41
  1035. .nr TW \n(81
  1036. .if t .if (\n(TW+\n(.o)>7.75i .tm Table at line 307 file ed2.tbl is too wide - \n(TW units
  1037. .fc  
  1038. .nr #T 0
  1039. .eo
  1040. .de T#
  1041. .ds #d .d
  1042. .if \(ts\n(.z\(ts\(ts .ds #d nl
  1043. .mk ##
  1044. .nr ## -1v
  1045. ..
  1046. .ec
  1047. .ta \n(80u \n(81u 
  1048. \&\h'|\n(40u'\f3/strange/\fP\h'|\n(41u'tells edit to find the characters ``strange'' in the text
  1049. .ta \n(80u \n(81u 
  1050. \&\h'|\n(40u'\f3s\fP\h'|\n(41u'tells edit to make a substitution
  1051. .ta \n(80u \n(81u 
  1052. \&\h'|\n(40u'\f3/strange, but //\fP\h'|\n(41u'substitutes nothing at all for the characters ``strange, but ''
  1053. .fc
  1054. .nr T. 1
  1055. .T# 1
  1056. .if \n(35>0 .fi
  1057. .in -1i
  1058. .TE
  1059. .PP
  1060. You should note the space after ``but'' in ``/strange, but /''. 
  1061. If you do not indicate that the space is to be taken out,
  1062. your line will read:
  1063. .DS I 1i
  1064. .if t Text editing is   nice.
  1065. .if n Text editing is  nice.
  1066. .DE
  1067. which looks a little funny   
  1068. because of the extra space between ``is'' and ``nice''.
  1069. Again, we realize from this that a blank space
  1070. is a real character to a computer, and in editing text
  1071. we need to be aware of spaces
  1072. within a line just as we would be aware of an ``a'' or 
  1073. a ``4''.
  1074. .SH
  1075. Another way to list what's in the buffer (z)
  1076. .PP
  1077. Although the print command is useful for looking at specific lines
  1078. in the buffer,
  1079. other commands may be more convenient for
  1080. viewing large sections of text.
  1081. You can ask to see a screen full of text at a time
  1082. by using the command
  1083. .B z.
  1084. If you type
  1085. .DS I 1i
  1086. :\|\fB1z
  1087. .R
  1088. .DE
  1089. edit will start with line 1 and continue printing lines,
  1090. stopping either when the screen of
  1091. your terminal is full
  1092. or when the last line in the buffer has been printed.
  1093. If you want to read the next segment of text, type the command
  1094. .DS I 1i
  1095. :\|\fBz
  1096. .DE
  1097. If no starting line number is given for the z command,
  1098. printing will start at the ``current'' line, in this case the
  1099. last line printed.
  1100. Viewing lines in the buffer one screen full at a time
  1101. is known as \fIpaging\fR.
  1102. Paging can also be used to print
  1103. a section of text on a hard-copy terminal.
  1104. .SH
  1105. Saving the modified text
  1106. .PP
  1107. This seems to be a good place to pause in our work,
  1108. and so we should end the second session.
  1109. If you (in haste) type ``q'' to quit the session
  1110. your dialogue with edit will be:
  1111. .DS I 1i
  1112. :\|\fBq
  1113. .R
  1114. No write since last change (:quit! overrides)
  1115. :
  1116. .DE
  1117. This is edit's warning that you have not written
  1118. the modified contents of the buffer to disk.
  1119. You run the risk of losing the work you did
  1120. during the editing session since you typed the latest write
  1121. command.
  1122. Because in this lesson we have not written
  1123. to disk at all, everything we have done
  1124. would have been lost
  1125. if edit had obeyed the \fBq\fR command.
  1126. If you did not want to save the work done during
  1127. this editing session, you would have to type ``q!''
  1128. or (``quit!'')
  1129. to confirm that you indeed wanted to end the session
  1130. immediately,
  1131. leaving the file as it was
  1132. after the most recent ``write'' command.
  1133. However,
  1134. since you want to save what
  1135. you have edited, you need to type:
  1136. .DS I 1i
  1137. :\|\fBw
  1138. .R
  1139. "text" 6 lines, 171 characters
  1140. .DE
  1141. and then follow with the commands to quit and logout:
  1142. .DS I 1i
  1143. :\|\fBq
  1144. % \fBlogout\fR
  1145. .DE
  1146. and hang up the phone or turn off the terminal when
  1147. \s-2UNIX\s0 asks for a name.
  1148. Terminals connected to the port selector
  1149. will stop after the logout command,
  1150. and pressing keys on the keyboard will do nothing.
  1151. .sp 1
  1152. .PP
  1153. This is the end of the second session on \s-2UNIX\s0 text editing.
  1154. .bp
  1155. .TL
  1156. Session 3
  1157. .SH
  1158. Bringing text into the buffer (e)
  1159. .PP
  1160. Login to \s-2UNIX\s0 and make contact with edit.  
  1161. You should try to login without
  1162. looking at the notes, but if you must
  1163. then by all means do.
  1164. .PP
  1165. Did you remember to give the name of the file
  1166. you wanted to edit?
  1167. That is, did you type
  1168. .DS I 1i
  1169. % \fBedit text\fR
  1170. .DE
  1171. or simply
  1172. .DS I 1i
  1173. % \fBedit\fR
  1174. .DE
  1175. Both ways get you in contact with edit, but the first way
  1176. will bring a copy of the file named ``text'' into
  1177. the buffer.  
  1178. If you did forget to tell edit the name of your file,
  1179. you can get it into the buffer by
  1180. typing:
  1181. .DS I 1i
  1182. :\|\fBe text
  1183. .R
  1184. "text" 6 lines, 171 characters
  1185. .DE
  1186. The command
  1187. .B edit,
  1188. which may be abbreviated \fBe\fR,
  1189. tells edit that you want
  1190. to erase anything that might already be in 
  1191. the buffer and bring a copy of the file ``text'' into the buffer
  1192. for editing.
  1193. You may also use the edit (e) command to change files in
  1194. the middle of an editing session,
  1195. or to give edit the name of a new file that you want to create.
  1196. Because the edit command clears the buffer,
  1197. you will receive a warning if you try to edit a new file without
  1198. having saved a copy of the old file.
  1199. This gives you a chance to write the contents of the buffer to disk
  1200. before editing the next file.
  1201. .SH
  1202. Moving text in the buffer (m)
  1203. .PP
  1204. Edit allows you to move lines of text
  1205. from one location in the buffer to another
  1206. by means of the
  1207. .B move
  1208. (\fBm\fR) command.
  1209. The first two examples are for illustration only,
  1210. though after you have read this Session
  1211. you are welcome to return to them for practice.
  1212. The command
  1213. .DS I 1i
  1214. :\|\fB2,4m$
  1215. .R
  1216. .DE
  1217. directs edit to move lines 2, 3, and 4
  1218. to the end of the buffer ($).  
  1219. The format for the move command is that you specify
  1220. the first line to be moved, the last line to be moved,
  1221. the move command ``m'', and the line after which
  1222. the moved text is to be placed.
  1223. So,
  1224. .DS I 1i
  1225. :\|\fB1,3m6
  1226. .R
  1227. .DE
  1228. would instruct edit to move lines 1 through 3 (inclusive) 
  1229. to a location after line 6 in the buffer.
  1230. To move only one line, say, line 4,
  1231. to a location in the buffer after line 5, 
  1232. the command would be ``4m5''.
  1233. .PP
  1234. Let's move some text using the command:
  1235. .DS I 1i
  1236. :\|\fB5,$m1
  1237. .R
  1238. 2 lines moved
  1239. it does illustrate the editor.
  1240. .DE
  1241. After executing a command that moves more than one line of the buffer,
  1242. edit tells how many lines were affected by the move
  1243. and prints the last moved line for your inspection.
  1244. If you want to see more than just the last line,
  1245. you can then
  1246. use the print (p), z, or number (nu) command to view more text.
  1247. The buffer should now contain:
  1248. .DS I 1i
  1249. This is some sample text.
  1250. It doesn't mean much here, but
  1251. it does illustrate the editor.
  1252. And this is some more text.
  1253. Text editing is nice.
  1254. This is text added in Session 2.
  1255. .DE
  1256. You can restore the original order by typing:
  1257. .DS I 1i
  1258. :\|\fB4,$m1
  1259. .R
  1260. .DE
  1261. or, combining context searching and the move command:
  1262. .DS I 1i
  1263. :\|\fB/And this is some/,/This is text/m/This is some sample/
  1264. .R
  1265. .DE
  1266. (Do not type both examples here!)
  1267. The problem with combining context searching
  1268. with the move command 
  1269. is that your chance of making a typing error
  1270. in such a long command is greater than
  1271. if you type line numbers.
  1272. .SH
  1273. Copying lines (copy)
  1274. .PP
  1275. The
  1276. .B copy
  1277. command
  1278. is used to make a second copy of specified lines,
  1279. leaving the original lines where they were.
  1280. Copy
  1281. has the same format as the move command, for example:
  1282. .DS I 1i
  1283. :\|\fB2,5copy $
  1284. .R
  1285. .DE
  1286. makes a copy of lines 2 through 5,
  1287. placing the added lines after the buffer's end ($).
  1288. Experiment with the copy command
  1289. so that you can become familiar with how it works.
  1290. Note that the shortest abbreviation for copy is
  1291. \f3co\f1 (and
  1292. not the letter ``c'', which has another meaning).
  1293. .SH
  1294. Deleting lines (d)
  1295. .PP
  1296. Suppose you want to delete 
  1297. the line
  1298. .DS I 1i
  1299. This is text added in Session 2.
  1300. .DE
  1301. from the buffer.
  1302. If you know the number of the line to be deleted,
  1303. you can type
  1304. that number followed by
  1305. \fBdelete\fR or \fBd\fR.
  1306. This example deletes line 4,
  1307. which is ``This is text added in Session 2.''
  1308. if you typed the commands
  1309. suggested so far.
  1310. .DS I 1i
  1311. :\|\fB4d
  1312. .R
  1313. It doesn't mean much here, but
  1314. .DE
  1315. Here ``4'' is the number of the line to be deleted,
  1316. and ``delete'' or ``d'' is the command to delete the line.
  1317. After executing the delete command,
  1318. edit prints the line that has become the current line (``.'').
  1319. .PP
  1320. If you do not happen to know the line number
  1321. you can search for the line and then delete it using this
  1322. sequence of commands:
  1323. .DS I 1i
  1324. :\|\fB/added in Session 2./
  1325. .R
  1326. This is text added in Session 2.
  1327. :\|\fBd
  1328. .R
  1329. It doesn't mean much here, but
  1330. .DE
  1331. The ``/added in Session 2./''
  1332. asks edit to locate and print
  1333. the line containing the indicated text,
  1334. starting its search at the current line
  1335. and moving line by line
  1336. until it finds the text.
  1337. Once you are sure that you have correctly specified the line
  1338. you want to delete,
  1339. you can enter the delete (d) command.
  1340. In this case it is not necessary to
  1341. specify a line number before the ``d''.
  1342. If no line number is given,
  1343. edit deletes the current line (``.''),
  1344. that is, the line found by our search.
  1345. After the deletion, your buffer should contain:
  1346. .DS I 1i
  1347. This is some sample text.
  1348. And this is some more text.
  1349. Text editing is nice.
  1350. It doesn't mean much here, but
  1351. it does illustrate the editor.
  1352. And this is some more text.
  1353. Text editing is nice.
  1354. This is text added in Session 2.
  1355. It doesn't mean much here, but
  1356. .DE
  1357. To delete both lines 2 and 3:
  1358. .DS I 1i
  1359. And this is some more text.
  1360. Text editing is nice.
  1361. .DE
  1362. you type
  1363. .DS I 1i
  1364. :\|\f32,3d\f1
  1365. 2 lines deleted
  1366. .DE
  1367. which specifies the range of lines from 2 to 3,
  1368. and the operation on those lines \(em ``d'' for delete.
  1369. If you delete more than one line
  1370. you will receive a message
  1371. telling you the number of lines deleted,
  1372. as indicated in the example above.
  1373. .PP
  1374. The previous example assumes that you know the line numbers for
  1375. the lines to be deleted.
  1376. If you do not you might combine the search command
  1377. with the delete command:
  1378. .DS I 1i
  1379. :\|\fB/And this is some/,/Text editing is nice./d
  1380. .R
  1381. .DE
  1382. .SH
  1383. A word or two of caution
  1384. .PP
  1385. In using the search function to locate lines to
  1386. be deleted you should be
  1387. .B
  1388. absolutely sure
  1389. .R
  1390. the characters you give as the basis for the search
  1391. will take edit to the line you want deleted.
  1392. Edit will search for the first
  1393. occurrence of the characters starting from where
  1394. you last edited \-
  1395. that is, from the line you see printed if you type dot (.).
  1396. .PP
  1397. A search based on too few
  1398. characters may result in the wrong lines being deleted,
  1399. which edit will do as easily as if you had meant it.
  1400. For this reason, it is usually safer
  1401. to specify the search and then delete in two separate steps,
  1402. at least until you become familiar enough with using the editor
  1403. that you understand how best to specify searches.
  1404. For a beginner it is not a bad idea to double-check
  1405. each command before pressing \s-2RETURN\s+2 to send the command on its way.
  1406. .SH
  1407. Undo (u) to the rescue
  1408. .PP
  1409. The
  1410. .B
  1411. undo (u)
  1412. .R
  1413. command has the ability to
  1414. reverse the effects of the last command that changed the buffer.
  1415. To undo the previous command, type
  1416. ``u'' or ``undo''.
  1417. Undo can rescue
  1418. the contents of the buffer from many an unfortunate mistake.
  1419. However, its powers are not unlimited,
  1420. so it is still wise to be reasonably
  1421. careful about the commands you give.
  1422. .PP
  1423. It is possible to undo only commands which
  1424. have the power to change the buffer \(em for example,
  1425. delete, append, move, copy, substitute, and even undo itself.
  1426. The commands write (w) and edit (e), which interact with disk files,
  1427. cannot be undone, nor can commands that do not change
  1428. the buffer, such as print.
  1429. Most importantly,
  1430. the
  1431. .B only
  1432. command that can be reversed by undo
  1433. is the
  1434. last ``undo-able'' command you typed.
  1435. You can use control-H and @ to change
  1436. commands while you are typing them,
  1437. and undo to reverse the effect of the commands
  1438. after you have typed them and pressed \s-2RETURN\s+2.
  1439. .PP
  1440. To illustrate,
  1441. let's issue an undo command.
  1442. Recall that the last buffer-changing command we gave deleted
  1443. the lines formerly numbered 2 and 3.
  1444. Typing undo at this moment will reverse the effects
  1445. of the deletion, causing those two lines to be
  1446. replaced in the buffer.
  1447. .DS I 1i
  1448. :\|\fBu
  1449. .R
  1450. 2 more lines in file after undo
  1451. And this is some more text.
  1452. .DE
  1453. Here again, edit informs you if the command affects more
  1454. than one line,
  1455. and prints
  1456. the text of the line which is now ``dot'' (the current line).
  1457. .SH
  1458. More about the dot (.) and buffer end ($)
  1459. .PP
  1460. The function assumed by the symbol dot depends on its context.
  1461. It can be used:
  1462. .IP
  1463. 1.  to exit from append mode; we type dot (and only a dot) on
  1464. a line and press \s-2RETURN\s+2;
  1465. .IP
  1466. 2.  to refer to the line we are at in the buffer.
  1467. .LP
  1468. Dot can also be combined with the equal sign to get
  1469. the number of the line currently being edited:
  1470. .DS I 1i
  1471. :\|\fB\&.=
  1472. .R
  1473. .DE
  1474. If we type ``\fB.\fR='' we are asking for the number of the line,
  1475. and if we type ``\fB.\fR'' we are asking for the text of the line.
  1476. .PP
  1477. In this editing session and the last, we used the dollar
  1478. sign to indicate the end of the buffer
  1479. in commands such as print, copy, and move.
  1480. The dollar sign as a command asks edit to print the last
  1481. line in the buffer.
  1482. If the dollar sign is combined with the equal sign (\f3$=\f1)
  1483. edit will print the line number corresponding to the
  1484. last line in the buffer.
  1485. .PP
  1486. ``\fB.\fR'' and ``$'', then, represent line numbers.
  1487. Whenever appropriate, these symbols can be used in
  1488. place of line numbers in commands.
  1489. For example
  1490. .DS I 1i
  1491. :\|\fB\s+2.\s-2,$d
  1492. .R
  1493. .DE
  1494. instructs edit to delete all lines from the current line (\fB.\fR)
  1495. to the end of the buffer.
  1496. .SH
  1497. Moving around in the buffer  (+ and \-)
  1498. .PP
  1499. When you are editing
  1500. you often want
  1501. to go back and re-read a previous line.
  1502. You could specify a context search for a line you want to
  1503. read if you remember some of its text,
  1504. but if you simply want to see what was written a few, say 3, lines
  1505. ago, you can type
  1506. .DS I 1i
  1507. \-3p
  1508. .DE
  1509. This tells edit to move back to a position 3 lines
  1510. before the current line (.)
  1511. and print that line.
  1512. You can move forward in the buffer similarly:
  1513. .DS I 1i
  1514. +2p
  1515. .DE
  1516. instructs edit to print the line that is 2
  1517. ahead of your current position.
  1518. .PP
  1519. You may use ``+'' and ``\-'' in any command where edit
  1520. accepts line numbers.
  1521. Line numbers specified with ``+'' or ``\-''
  1522. can be combined to print a range of lines.
  1523. The command
  1524. .DS I 1i
  1525. :\|\fB\-1,+2copy$
  1526. .R
  1527. .DE
  1528. makes a copy of 4 lines:  the current line, the line before it,
  1529. and the two after it.
  1530. The copied lines will be placed after the last line
  1531. in the buffer ($),
  1532. and the original lines referred to by ``\-1'' and ``+2''
  1533. remain where they are.
  1534. .PP
  1535. Try typing only ``\-''; you will move back one line just as
  1536. if you had typed ``\-1p''.
  1537. Typing the command ``+'' works similarly.
  1538. You might also try typing a few plus or minus signs in a row
  1539. (such as ``+++'') to see edit's response.
  1540. Typing \s-2RETURN\s+2 alone on a line is the equivalent
  1541. of typing ``+1p''; it will move you one line ahead in the buffer
  1542. and print that line.
  1543. .PP
  1544. If you are at the last line of the buffer and try
  1545. to move further ahead, perhaps by typing a ``+'' or
  1546. a carriage return alone on the line,
  1547. edit will remind you that you are at the end of the buffer:
  1548. .sp
  1549. .nf
  1550. .ti 1i
  1551. At end-of-file
  1552. .br
  1553. or
  1554. .ti 1i
  1555. Not that many lines in buffer
  1556. .fi
  1557. .LP
  1558. Similarly, if you try to move to a position before the first line,
  1559. edit will print one of these messages:
  1560. .sp
  1561. .nf
  1562. .ti 1i
  1563. Nonzero address required on this command
  1564. .br
  1565. or
  1566. .ti 1i
  1567. Negative address \- first buffer line is 1
  1568. .fi
  1569. .LP
  1570. The number associated with a buffer line is the line's ``address'',
  1571. in that it can be used to locate the line.
  1572. .SH
  1573. Changing lines (c)
  1574. .PP
  1575. You can also delete certain lines and
  1576. insert new text in their place.
  1577. This can be accomplished easily with the
  1578. .B "change (c)"
  1579. command.
  1580. The change command instructs edit to delete specified lines
  1581. and then switch to text input mode to
  1582. accept the text that will replace them.
  1583. Let's say you want to change the first two lines in the buffer:
  1584. .DS I 1i
  1585. This is some sample text.
  1586. And this is some more text.
  1587. .DE
  1588. to read
  1589. .DS I 1i
  1590. This text was created with the \s-2UNIX\s0 text editor.
  1591. .DE
  1592. To do so, you type:
  1593. .DS I 1i
  1594. :\|\fB1,2c
  1595. .R
  1596. 2 lines changed
  1597. .B
  1598. This text was created with the \s-2UNIX\s0 text editor.
  1599. \s+2\&.\s-2
  1600. .R
  1601. :
  1602. .DE
  1603. In the command
  1604. .B 1,2c
  1605. we specify that we want to change
  1606. the range of lines beginning with 1 and ending with 2
  1607. by giving line numbers as with the print command.
  1608. These lines will be deleted.
  1609. After you type \s-2RETURN\s+2 to end the change command,
  1610. edit notifies you if more than one line will be changed
  1611. and places you in text input mode.
  1612. Any text typed on the following lines will be inserted into
  1613. the position where lines were deleted by the change command.
  1614. .B
  1615. You will remain in text input mode until you exit in the usual way,
  1616. by typing a period alone on a line.
  1617. .R
  1618. Note that the number of lines added to the buffer need not be
  1619. the same as the number of lines deleted.
  1620. .sp 1
  1621. .PP
  1622. This is the end of the third session on text editing with \s-2UNIX\s0.
  1623. .bp
  1624. .SH
  1625. .ce 1
  1626. \s+2Session 4\s0
  1627. .sp
  1628. .PP
  1629. This lesson covers several topics, starting with
  1630. commands that apply throughout the buffer,
  1631. characters with special meanings,
  1632. and how to issue \s-2UNIX\s0 commands while in the editor.
  1633. The next topics deal with files:
  1634. more on reading and writing,
  1635. and methods of recovering files lost in a crash.
  1636. The final section suggests sources of further information.
  1637. .SH
  1638. Making commands global (g)
  1639. .PP
  1640. One disadvantage to the commands we have used for
  1641. searching or substituting is that if you
  1642. have a number of instances of a word to change 
  1643. it appears that you have to type the command 
  1644. repeatedly, once for
  1645. each time the change needs to be made.
  1646. Edit, however, provides a way to make commands
  1647. apply to the entire contents of the buffer \-
  1648. the
  1649. .B
  1650. global (g)
  1651. .R
  1652. command.
  1653. .PP
  1654. To print all lines
  1655. containing a certain sequence of characters
  1656. (say, ``text'')
  1657. the command is:
  1658. .DS I 1i
  1659. :\|\fBg/text/p
  1660. .R
  1661. .DE
  1662. The ``g'' instructs edit to
  1663. make a global search for all lines
  1664. in the buffer containing the characters  ``text''.
  1665. The ``p'' prints the lines found.
  1666. .PP
  1667. To issue a global command, start by typing a ``g'' and then a search
  1668. pattern identifying
  1669. the lines to be affected.
  1670. Then, on the same line, type the command to be
  1671. executed for the identified lines.
  1672. Global substitutions are frequently useful.
  1673. For example,
  1674. to change all instances of the word ``text'' to the word ``material''
  1675. the command would be a combination of the global search and the
  1676. substitute command:
  1677. .DS I 1i
  1678. :\|\fBg/text/s/text/material/g
  1679. .R
  1680. .DE
  1681. Note the ``g'' at the end of the global command,
  1682. which instructs edit to change
  1683. each and every instance of ``text'' to ``material''.
  1684. If you do not type the ``g'' at the end of the command
  1685. only the
  1686. .I first
  1687. instance of ``text'' \fIin each line\fR will be changed
  1688. (the normal result of the substitute command).
  1689. The ``g'' at the end of the command is independent of the ``g''
  1690. at the beginning.
  1691. You may give a command such as:
  1692. .DS I 1i
  1693. :\|\fB5s/text/material/g
  1694. .R
  1695. .DE
  1696. to change every instance of ``text'' in line 5 alone.
  1697. Further, neither command will change ``text'' to ``material''
  1698. if ``Text'' begins with a capital rather than a lower-case
  1699. .I t.
  1700. .PP
  1701. Edit does not automatically print the lines modified by a
  1702. global command.
  1703. If you want the lines to be printed, type a ``p''
  1704. at the end of the global command:
  1705. .DS I 1i
  1706. :\|\fBg/text/s/text/material/gp
  1707. .R
  1708. .DE
  1709. You should be careful
  1710. about using the global command in combination with any other \-
  1711. in essence, be sure of what you are telling edit to do
  1712. to the entire buffer.
  1713. For example,
  1714. .DS I 1i
  1715. :\|\fBg/ /d
  1716. .R
  1717. 72 less lines in file after global
  1718. .DE
  1719. will delete every line containing a blank anywhere in it.
  1720. This could adversely affect
  1721. your document, since most lines have spaces between words
  1722. and thus would be deleted.
  1723. After executing the global command,
  1724. edit will print a warning if the command added or deleted more than one line.
  1725. Fortunately, the undo command can reverse
  1726. the effects of a global command.
  1727. You should experiment with the global command
  1728. on a small file of text to see what it can do for you.
  1729. .SH
  1730. More about searching and substituting
  1731. .PP
  1732. In using slashes to identify a character string
  1733. that we want to search for or change,
  1734. we have always specified the exact characters.
  1735. There is a less tedious way to
  1736. repeat the same string of characters.
  1737. To change ``text'' to ``texts'' we may type either
  1738. .DS I 1i
  1739. :\|\fB/text/s/text/texts/
  1740. .R
  1741. .DE
  1742. as we have done in the past,
  1743. or a somewhat abbreviated command:
  1744. .DS I 1i
  1745. :\|\fB/text/s//texts/
  1746. .R
  1747. .DE
  1748. In this example, the characters to be changed
  1749. are not specified \-
  1750. there are no characters, not even a space,
  1751. between the two slash marks
  1752. that indicate what is to be changed.
  1753. This lack of characters between the slashes
  1754. is taken by the editor to mean
  1755. ``use the characters we last searched for as the characters to be changed.''
  1756. .PP
  1757. Similarly, the last context search may be repeated
  1758. by typing a pair of slashes with nothing between them:
  1759. .DS I 1i
  1760. :\|\fB/does/
  1761. .R
  1762. It doesn't mean much here, but
  1763. :\|\fB//
  1764. .R
  1765. it does illustrate the editor.
  1766. .DE
  1767. (You should note that the search command found the characters ``does''
  1768. in the word ``doesn't'' in the first search request.)
  1769. Because no characters are specified for the second search,
  1770. the editor scans the buffer for the next occurrence of the
  1771. characters ``does''.
  1772. .PP
  1773. Edit normally searches forward through the buffer,
  1774. wrapping around from the end of the buffer to the beginning,
  1775. until the specified character string is found.
  1776. If you want to search in the reverse direction,
  1777. use question marks (?) instead of slashes
  1778. to surround the characters you are searching for.
  1779. .PP
  1780. It is also possible
  1781. to repeat the last substitution
  1782. without having to retype the entire command.
  1783. An ampersand (&) used as a command
  1784. repeats the most recent substitute command,
  1785. using the same search and replacement patterns.
  1786. After altering the current line by typing
  1787. .DS I 1i
  1788. :\|\fBs/text/texts/
  1789. .R
  1790. .DE
  1791. you type
  1792. .DS I 1i
  1793. :\|\fB/text/&
  1794. .R
  1795. .DE
  1796. or simply
  1797. .DS I 1i
  1798. :\|\fB//&
  1799. .R
  1800. .DE
  1801. to make the same change on the next line in the buffer
  1802. containing the characters ``text''.
  1803. .SH
  1804. Special characters
  1805. .PP
  1806. Two characters have special meanings when
  1807. used in specifying searches:  ``$'' and ``^''.
  1808. ``$'' is taken by the editor to mean ``end of the line''
  1809. and is used to identify strings
  1810. that occur at the end of a line.
  1811. .DS I 1i
  1812. :\|\fBg/text.$/s//material./p
  1813. .R
  1814. .DE
  1815. tells the editor to search for all lines ending in ``text.''
  1816. (and nothing else, not even a blank space),
  1817. to change each final ``text.'' to ``material.'',
  1818. and print the changed lines.
  1819. .PP
  1820. The symbol ``^'' indicates the beginning of a line.
  1821. Thus,
  1822. .DS I 1i
  1823. :\|\fBs/^/1. /
  1824. .R
  1825. .DE
  1826. instructs the editor to insert ``1.'' and a space at the beginning
  1827. of the current line.
  1828. .PP
  1829. The characters ``$'' and ``^'' have special meanings only in the context
  1830. of searching.
  1831. At other times, they are ordinary characters.
  1832. If you ever need to search for a character that has a special meaning,
  1833. you must indicate that the
  1834. character is to lose temporarily
  1835. its special significance by typing another special character,
  1836. the backslash (\\), before it.
  1837. .DS I 1i
  1838. :\|\fBs/\\\\\&$/dollar/
  1839. .R
  1840. .DE
  1841. looks for the character ``$'' in the current
  1842. line and replaces it by the word ``dollar''.
  1843. Were it not for the backslash, the ``$'' would have represented
  1844. ``the end of the line'' in your search
  1845. rather than the character ``$''.
  1846. The backslash retains its special significance
  1847. unless it is preceded by another backslash.
  1848. .SH
  1849. Issuing \s-2UNIX\s0 commands from the editor
  1850. .PP
  1851. After creating several files with the editor,
  1852. you may want to delete files
  1853. no longer useful to you or ask for a list of your files.
  1854. Removing and listing files are not functions of the editor,
  1855. and so they require the use of \s-2UNIX\s0 system commands
  1856. (also referred to as ``shell'' commands, as
  1857. ``shell'' is the name of the program that processes \s-2UNIX\s0 commands).
  1858. You do not need to quit the editor to execute a \s-2UNIX\s0 command
  1859. as long as you indicate that it
  1860. is to be sent to the shell for execution.
  1861. To use the \s-2UNIX\s0 command
  1862. .B rm
  1863. to remove the file named ``junk'' type:
  1864. .DS I 1i
  1865. :\|\fB!rm junk
  1866. .R
  1867. !
  1868. :
  1869. .DE
  1870. The exclamation mark (!)
  1871. indicates that the rest of the line is to be processed as a shell command.
  1872. If the buffer contents have not been written since the last change,
  1873. a warning will be printed before the command is executed:
  1874. .DS I 1i
  1875. [No write since last change]
  1876. .DE
  1877. The editor prints a ``!'' when the command is completed.
  1878. Other tutorials describe useful features of the system,
  1879. of which an editor is only one part.
  1880. .SH
  1881. Filenames and file manipulation
  1882. .PP
  1883. Throughout each editing session,
  1884. edit keeps track of the name of the file being edited as the
  1885. .I "current filename."
  1886. Edit remembers as the current filename the name given
  1887. when you entered the editor.
  1888. The current filename changes whenever the edit (e) command
  1889. is used to specify a new file.
  1890. Once edit has recorded a current filename,
  1891. it inserts that name into any command where a filename has been omitted.
  1892. If a write command does not specify a file,
  1893. edit, as we have seen, supplies the current filename.
  1894. If you are editing a file named ``draft3'' having 283 lines in it,
  1895. you can have the editor write onto a different file
  1896. by including its name in the write command:
  1897. .DS I 1i
  1898. :\fB\|w chapter3
  1899. .R
  1900. "chapter3" [new file] 283 lines, 8698 characters
  1901. .DE
  1902. The current filename remembered by the editor
  1903. .I
  1904. will not be changed as a result of the write command.
  1905. .R
  1906. Thus, if the next write command
  1907. does not specify a name,
  1908. edit will write onto the current file (``draft3'')
  1909. and not onto the file ``chapter3''.
  1910. .SH
  1911. The file (f) command
  1912. .PP
  1913. To ask for the current filename, type
  1914. .B file
  1915. (or
  1916. .B f ).
  1917. In response, the editor provides current information about the buffer,
  1918. including the filename, your current position, the number of
  1919. lines in the buffer,
  1920. and the percent of the distance through the file
  1921. your current location is.
  1922. .DS I 1i
  1923. :\|\fBf
  1924. .R
  1925. "text" [Modified] line 3 of 4 --75%--
  1926. .DE
  1927. .\"The expression ``[Edited]'' indicates that the buffer contains
  1928. .\"either the editor's copy of the existing file ``text''
  1929. .\"or a file which you are just now creating.
  1930. If the contents of the buffer have changed
  1931. since the last time the file was written,
  1932. the editor will tell you that the file has been ``[Modified]''.
  1933. After you save the changes by writing onto a disk file,
  1934. the buffer will no longer be considered modified:
  1935. .DS I 1i
  1936. :\|\fBw
  1937. .R
  1938. "text" 4 lines, 88 characters
  1939. :\|\fBf
  1940. .R
  1941. "text" line 3 of 4 --75%--
  1942. .DE
  1943. .SH
  1944. Reading additional files (r)
  1945. .PP
  1946. The
  1947. \f3read (r)\f1 command allows you to add the contents of a file
  1948. to the buffer
  1949. at a specified location,
  1950. essentially copying new lines
  1951. between two existing lines.
  1952. To use it, specify the line after which the new text will be placed,
  1953. the \f3read (r)\f1 command,
  1954. and then the name of the file.
  1955. If you have a file named ``example'', the command
  1956. .DS I 1i
  1957. :\|\fB$r example
  1958. .R
  1959. "example" 18 lines, 473 characters
  1960. .DE
  1961. reads the file ``example''
  1962. and adds it to the buffer after the last line.
  1963. The current filename is not changed by the read command.
  1964. .SH
  1965. Writing parts of the buffer
  1966. .PP
  1967. The
  1968. .B
  1969. write (w)
  1970. .R
  1971. command can write all or part of the buffer
  1972. to a file you specify.
  1973. We are already familiar with
  1974. writing the entire contents of the
  1975. buffer to a disk file.
  1976. To write only part of the buffer onto a file,
  1977. indicate the beginning and ending lines before the write command,
  1978. for example
  1979. .DS I 1i
  1980. :\|\fB45,$w ending
  1981. .R
  1982. .DE
  1983. Here all lines from 45 through the end of the buffer
  1984. are written onto the file named
  1985. .I ending.
  1986. The lines remain in the buffer
  1987. as part of the document you are editing,
  1988. and you may continue to edit the entire buffer.
  1989. Your original file is unaffected
  1990. by your command to write part of the buffer
  1991. to another file.
  1992. Edit still remembers whether you have saved changes to the buffer
  1993. in your original file or not.
  1994. .SH
  1995. Recovering files
  1996. .PP
  1997. Although it does not happen very often,
  1998. there are times \s-2UNIX\s+2 stops working
  1999. because of some malfunction.
  2000. This situation is known as a \fIcrash\fR.
  2001. Under most circumstances,
  2002. edit's crash recovery feature
  2003. is able to save work to within a few lines of changes
  2004. before a crash (or an accidental phone hang up).
  2005. If you lose the contents of an editing buffer in a system crash,
  2006. you will normally receive mail when you login that gives
  2007. the name of the recovered file.
  2008. To recover the file,
  2009. enter the editor and type the command
  2010. .B recover
  2011. (\fBrec\fR),
  2012. followed by the name of the lost file.
  2013. For example,
  2014. to recover the buffer for an edit session
  2015. involving the file ``chap6'', the command is:
  2016. .DS I 1i
  2017. .R
  2018. :\|\fBrecover chap6
  2019. .R
  2020. .DE
  2021. Recover is sometimes unable to save the entire buffer successfully,
  2022. so always check the contents of the saved buffer carefully
  2023. before writing it back onto the original file.
  2024. For best results,
  2025. write the buffer to a new file temporarily
  2026. so you can examine it without risk to the original file.
  2027. Unfortunately,
  2028. you cannot use the recover command
  2029. to retrieve a file you removed
  2030. using the shell command \f3rm\f1.
  2031. .SH
  2032. Other recovery techniques
  2033. .PP
  2034. If something goes wrong when you are using the editor,
  2035. it may be possible to save your work by using the command
  2036. .B preserve
  2037. (\fBpre\fR),
  2038. which saves the buffer as if the system had crashed.
  2039. If you are writing a file and you get the message
  2040. ``Quota exceeded'', you have tried to use more disk storage
  2041. than is allotted to your account.
  2042. .I
  2043. Proceed with caution
  2044. .R
  2045. because it is likely that only a part
  2046. of the editor's buffer is now present in the file you tried to write.
  2047. In this case you should use the shell escape from the editor (!)
  2048. to remove some files you don't need and try to write
  2049. the file again.
  2050. If this is not possible and you cannot find someone to help you,
  2051. enter the command
  2052. .DS I 1i
  2053. :\|\fBpreserve
  2054. .R
  2055. .DE
  2056. and wait for the reply,
  2057. .DS I 1i
  2058. File preserved.
  2059. .DE
  2060. If you do not receive this reply,
  2061. seek help immediately.
  2062. Do not simply leave the editor.
  2063. If you do, the buffer will be lost, 
  2064. and you may not be able to save your file.
  2065. If the reply is ``File preserved.''
  2066. you can leave the editor
  2067. (or logout)
  2068. to remedy the situation.
  2069. After a preserve, you can use the recover command
  2070. once the problem has been corrected,
  2071. or the \fB\-r\fR option of the edit command
  2072. if you leave the editor and want to return.
  2073. .PP
  2074. If you make an undesirable change to the buffer
  2075. and type a write command before discovering your mistake,
  2076. the modified version will replace any previous version of the file.
  2077. Should you ever lose a good version of a document in this way,
  2078. do not panic and leave the editor.
  2079. As long as you stay in the editor,
  2080. the contents of the buffer remain accessible.
  2081. Depending on the nature of the problem,
  2082. it may be possible
  2083. to restore the buffer to a more complete
  2084. state with the undo command.
  2085. After fixing the damaged buffer, you can again write the file
  2086. to disk.
  2087. .SH
  2088. Further reading and other information
  2089. .PP
  2090. Edit is an editor designed for beginning and casual users.
  2091. It is actually a version of a more powerful editor called
  2092. .I ex.
  2093. These lessons are intended to introduce you to the editor
  2094. and its more commonly-used commands.
  2095. We have not covered all of the editor's commands,
  2096. but a selection of commands
  2097. that should be sufficient to accomplish most of your editing tasks.
  2098. You can find out more about the editor in the
  2099. .I
  2100. Ex Reference Manual,
  2101. .R
  2102. which is applicable to both
  2103. .I ex
  2104. and
  2105. .I edit.
  2106. One way to become familiar with the manual is to begin by reading
  2107. the description of commands that you already know.
  2108. .bd I 3
  2109. .SH
  2110. Using
  2111. .I ex
  2112. .fl
  2113. .bd I
  2114. .PP
  2115. As you become more experienced with using the editor,
  2116. you may still find that edit continues to meet your needs.
  2117. However, should you become interested in using 
  2118. .I ex,
  2119. it is easy to switch.
  2120. To begin an editing session with 
  2121. .I ex,
  2122. use the name
  2123. .B ex
  2124. in your command instead of
  2125. .B edit.
  2126. .PP
  2127. Edit commands also work in 
  2128. .I ex,
  2129. but the editing environment is somewhat different.
  2130. You should be aware of a few differences
  2131. between 
  2132. .I ex
  2133. and 
  2134. .I edit.
  2135. In edit, only the characters ``^'', ``$'', and ``\\'' have
  2136. special meanings in searching the buffer
  2137. or indicating characters to be changed by a substitute command.
  2138. Several additional characters have special
  2139. meanings in ex, as described in the
  2140. .I
  2141. Ex Reference Manual.
  2142. .R
  2143. Another feature of the edit environment prevents users from
  2144. accidently entering two alternative modes of editing,
  2145. .I open
  2146. and
  2147. .I visual,
  2148. in which
  2149. the editor behaves quite differently from normal command mode.
  2150. If you are using ex and you encounter strange behavior,
  2151. you may have accidently entered open mode by typing ``o''.
  2152. Type the \s-2ESC\s0 key and then a ``Q''
  2153. to get out of open or visual mode and back into
  2154. the regular editor command mode.
  2155. The document
  2156. .I
  2157. An Introduction to Display Editing with Vi\|\|
  2158. .R
  2159. provide full details of visual mode.
  2160. .bp
  2161. .SH
  2162. .ce 1
  2163. \s+2Index\s0
  2164. .LP
  2165. .sp 2
  2166. .2C
  2167. .nf
  2168. addressing, \fIsee\fR line numbers
  2169. ampersand, 20
  2170. append mode, 6-7
  2171. append (a) command, 6, 7, 9
  2172. ``At end of file'' (message), 18
  2173. backslash (\\), 21
  2174. buffer, 3
  2175. caret (^), 10, 20
  2176. change (c) command, 18
  2177. command mode, 5-6
  2178. ``Command not found'' (message), 6
  2179. context search, 10-12, 19-21
  2180. control characters (``^'' notation), 10
  2181. control-H, 7
  2182. copy (co) command, 15
  2183. corrections, 7, 16
  2184. current filename, 21
  2185. current line (\|.\|), 11, 17
  2186. delete (d) command, 15-16
  2187. dial-up, 5
  2188. disk, 3
  2189. documentation, 3, 23
  2190. dollar ($), 10, 11, 17, 20-21
  2191. dot (\f3\|.\|\f1) 11, 17
  2192. edit (text editor), 3, 5, 23
  2193. edit (e) command, 5, 9, 14
  2194. editing commands:
  2195. .in +.25i
  2196. append (a), 6, 7, 9
  2197. change (c), 18
  2198. copy (co), 15
  2199. delete (d), 15-16
  2200. edit (text editor), 3, 5, 23
  2201. edit (e), 5, 9, 14
  2202. file (f), 21-22
  2203. global (g), 19
  2204. move (m), 14-15
  2205. number (nu), 11
  2206. preserve (pre), 22-23
  2207. print (p), 10
  2208. quit (q), 8, 13
  2209. read (r), 22
  2210. recover (rec), 22, 23
  2211. substitute (s), 11-12, 19, 20
  2212. undo (u), 16-17, 23
  2213. write (w), 8, 13, 21, 22
  2214. z, 12-13
  2215. ! (shell escape), 21
  2216. $=, 17
  2217. +, 17
  2218. \-, 17
  2219. //, 12, 20
  2220. ??, 20
  2221. \&., 11, 17
  2222. \&.=, 11, 17
  2223. .in -.25i
  2224. entering text, 3, 6-7
  2225. erasing
  2226. .in +.25i
  2227. characters (^H), 7
  2228. lines (@), 7
  2229. .in -.25i
  2230. error corrections, 7, 16
  2231. ex (text editor), 23
  2232. \fIEx Reference Manual\fR, 23
  2233. exclamation (!), 21
  2234. file, 3
  2235. file (f) command, 21-22
  2236. file recovery, 22-23
  2237. filename, 3, 21
  2238. global (g) command, 19
  2239. input mode, 6-7
  2240. Interrupt (message), 9
  2241. line numbers, \fIsee also\fR current line
  2242. .in +.25i
  2243. dollar sign ($), 10, 11, 17
  2244. dot (\|.\|), 11, 17
  2245. relative (+ and \-), 17
  2246. .in -.25i
  2247. list, 10
  2248. logging in, 4-6
  2249. logging out, 8
  2250. ``Login incorrect'' (message), 5
  2251. minus (\-), 17
  2252. move (m) command, 14-15
  2253. ``Negative address\(emfirst buffer line is 1'' (message), 18
  2254. ``No current filename'' (message), 8
  2255. ``No such file or directory'' (message), 5, 6
  2256. ``No write since last change'' (message), 21
  2257. non-printing characters, 10
  2258. ``Nonzero address required'' (message), 18
  2259. ``Not an editor command'' (message), 6
  2260. ``Not that many lines in buffer'' (message), 18
  2261. number (nu) command, 11
  2262. password, 5
  2263. period (\|.\|), 11, 17
  2264. plus (+), 17
  2265. preserve (pre) command, 22-23
  2266. print (p) command, 10
  2267. program, 3
  2268. prompts
  2269. .in .25i
  2270. % (\s-2UNIX\s0), 5
  2271. : (edit), 5, 6, 7
  2272. \0 (append), 7
  2273. .in -.25i
  2274. question (?), 20
  2275. quit (q) command, 8, 13
  2276. read (r) command, 22
  2277. recover (rec) command, 22, 23
  2278. recovery, \fIsee\fR\| file recovery
  2279. references, 3, 23
  2280. remove (rm) command, 21, 22
  2281. reverse command effects (undo), 16-17, 23
  2282. searching, 10-12, 19-21
  2283. shell, 21
  2284. shell escape (!), 21
  2285. slash (/), 11-12, 20
  2286. special characters (^, $, \\), 10, 11, 17, 20-21
  2287. substitute (s) command, 11-12, 19, 20
  2288. terminals, 4-5
  2289. text input mode, 7
  2290. undo (u) command, 16-17, 23
  2291. \s-1UNIX\s0, 3
  2292. write (w) command, 8, 13, 21, 22
  2293. z command, 12-13
  2294.  
  2295.