home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 318_01 / redman.doc < prev    next >
Text File  |  1990-06-18  |  38KB  |  884 lines

  1.  
  2. RED
  3. A Full Screen Text Editor
  4.  
  5. Version 7.0
  6. January 26, 1990
  7.  
  8.  
  9.  
  10. Written by
  11.  
  12. Edward K. Ream
  13. 1617 Monroe Street
  14. Madison, WI 53711
  15.  
  16.  
  17.  
  18.  
  19.  
  20. CHAPTER 1  BEFORE USING RED
  21.  
  22.  
  23. This chapter provides information you should know before using RED.  It
  24. lists the hardware and software required, it reminds you to create a backup
  25. copy of the distribution disk containing RED, and it lists the files that are
  26. distributed with the RED system.
  27.  
  28.  
  29. System Requirements
  30.  
  31. o An IBM PC/XT/AT computer or compatible with two floppy disks or a hard disk.
  32.  
  33. o The MS-DOS operating system.
  34.  
  35. o Either the Microsoft C compiler or the Turbo C compiler.  Minor
  36. modifications in RED's source code will allow RED to compile using other
  37. C compilers.
  38.  
  39.  
  40. Backing Up Your Disks
  41.  
  42. Please back up the distribution disks before using RED.  Use the DOS
  43. COPY command to copy all the files on the distribution disks to backup
  44. disks.  Your backup disks will be used as working disks.
  45.  
  46. The following files appear on your distribution disks.
  47.  
  48. File        Description
  49.  
  50. read.me        Please read this file first.
  51. redman.doc    This file.
  52. redtech.doc    Technical notes.
  53. red*.h        Header files for RED.
  54. red*.c        Source code files for RED.
  55. red.exe        Executable version of RED.
  56.  
  57. red.mak        Turboc C make file for red.exe.
  58. red.lnk        Turboc C link file for red.exe.
  59. mred.mmk    Microsoft C make files for red.exe.
  60. mred.ml        Microsoft C link files for red.exe.
  61.  
  62. sherlock.doc    Documentation for the Sherlockt debugging system.
  63. dummysl.h    Null definitions for all Sherlock macros.
  64. reddb.exe    Executable version of RED, with    Sherlock macros added.
  65.  
  66. red.mak        Turboc C make file for reddb.exe.
  67. red.lnk        Turboc C Link file for reddb.exe.
  68. mred.mmk    Microsoft C make file for reddb.exe.
  69. mred.ml        Microsoft C link file for reddb.exe.
  70.  
  71.  
  72.  
  73. CHAPTER 2:  REFERENCE GUIDE
  74.  
  75. This chapter tells you how to use REDDit describes RED's commands and
  76. functions, tells you how to use them and explains what to do about warning
  77. messages.  Each section discusses a particular activity or task that you do
  78. while creating, changing or saving a document.
  79.  
  80.  
  81. Starting RED
  82.  
  83. When RED starts up it does the following:
  84.  
  85. o Clears the screen and prints a welcoming message.  This signon message
  86. tells you what version of RED you are using and how to print help
  87. messages.  Help messages are simply reminders of what you can do with
  88. RED.
  89.  
  90. o Draws the prompt line at the top of the screen.  For now, just notice this
  91. top line; we'll discuss the information on it in a moment.
  92.  
  93. o Puts the cursor just below the prompt line.  The cursor is a distinctive
  94. character on the screen.  (On most video terminals the cursor is shown as a
  95. box or underline which blinks.)
  96.  
  97. o Draws the end-of-file marker or the third line of the screen.  This line
  98. looks like:
  99.  
  100. ----------------------------- End of file. ------------------------------------
  101.  
  102. Initially, most of the screen is blank because RED's buffer or internal
  103. memory doesn't contain any information.  You can think of the screen as a
  104. window into part of this buffer.  As you make additions, corrections and
  105. deletions to the buffer, those changes appear automatically on the screen.
  106. The purpose of the end-of-file marker is to make absolutely clear what the
  107. buffer does and does not contain.
  108.  
  109. Let's look again at the prompt line.  At the far left, you will see that the
  110. line says, 
  111.  
  112.     line:  1        column:  0
  113.  
  114. These two fields indicate which lines in the buffer and column on the screen
  115. that the cursor is on.   The next field says,
  116.  
  117.     ..no file..
  118.  
  119. indicating that the buffer does not contain any information from a file.
  120.  
  121. Finally, the prompt line tells you what mode RED is in--either edit mode,
  122. insert mode or overtype modes.  In most respects, RED works exactly the
  123. same regardless of mode; that makes RED simple to use.  However, some
  124. details on how RED works change depending on mode; that makes RED
  125. powerful.  We'll see later that not only can you make RED change modes
  126. easily, but you can have RED change modes automatically if you so desire.
  127. This feature allows you to make RED work exactly the way you want.
  128. We'll discuss modes shortly in complete detail.  For the moment, just notice
  129. what mode RED is now in.
  130.  
  131. At your option, you have have RED automatically load a text file into RED's
  132. internal memory (the buffer) when RED initially starts up.  For example, if
  133. you had invoked RED as follows:
  134.  
  135.     red document.txt
  136.  
  137. then RED would have loaded the file document.txt into the buffer already.
  138. In that case the screen would not be blank but instead would show you the
  139. first several lines in the file and the prompt line would be "document.txt"
  140. instead of "..no file.."
  141.  
  142.  
  143. Using Function and Control Keys
  144.  
  145. The term function key refers to a key on your keyboard that does one and
  146. only one action or function.  Just about everything you do with RED
  147. involves using function keys---they are used to change modes, to insert or
  148. delete lines and characters, to move the cursor, to split and join lines and to
  149. start commands.  There is also a "repeat" function key that repeats the
  150. previous function.  All function keys can be used in insert, overtype and
  151. edit modes and all function keys do the same thing, regardless of the current
  152. mode.
  153.  
  154. RED needs to be able to distinguish function keys from what you are typing
  155. into the buffer.  Thus, function keys must be assigned to control keys on
  156. your keyboard.  A control key is typed by holding down the key marked
  157. CTRL on your keyboard while typing another key.  For example, you type
  158. the "control c key" (abbreviated control-c) by typing the letter c while
  159. holding down the CTRL key.
  160.  
  161. Throughout this chapter, the name of each function key is followed in
  162. parenthesis by the control key assigned to it by default.  For example, this
  163. chapter refers to the split function key as split (control-s).  So in order to
  164. press the split function key you must actually press the control-s key on
  165. your keyboard.
  166.  
  167.  
  168. Changing Modes
  169.  
  170. RED has three modes:  edit mode, insert mode and overtype mode and all
  171. function keys act the same regardless of modeDthe only difference between
  172. the three modes is what happens when you type a non-control character.
  173. You use three  different keys to switch RED between modes--the enter
  174. iNsert (control-n), the enter overType (control-t) and enter edit (control-e)
  175. function keys.
  176.  
  177. Besides these three keys which explicitly change from one mode to another,
  178. RED can change from one mode to another automatically in three situations:
  179.  
  180. 1) after every command,
  181. 2) after inserting new lines and
  182. 3) whenever the cursor moves up or down one line.
  183.  
  184. You can change how RED switches modes using three sets of commands:
  185. def0edit, def0ins, def0over, def1edit, def1ins, def1over, def2edit, def2ins,
  186. and def2over.  (We haven't discussed commands yet, so if you are reading
  187. this for the first time just realize that how RED switches between modes
  188. isn't carved in stone.)
  189.  
  190. I prefer to use a hybrid combination of edit mode and insert modeDI
  191. configure RED so it acts as if I had issued def0edit, def1ins and def2edit
  192. commands.  For example, to make RED into an "overtype mode editor" just
  193. issue the def0over, def1over and def2over commands.  You'll never see
  194. insert or edit modes again unless you switch to them explicitly.  
  195.  
  196.  
  197. Inserting Characters with Insert and Overtype Modes
  198.  
  199. In this section we'll look at insert and overtype modes, leaving edit mode
  200. for much later.  Let's discuss insert mode first, so if RED is not already in
  201. insert mode press the enter insert (control-n) function key.  Notice that the
  202. prompt line indicates that the mode has changed.
  203.  
  204. In insert mode, any plain (i.e., non-control) character you type is inserted
  205. into the buffer without replacing any other information.  Characters to the
  206. right of the cursor "move over" to allow room for the new character.  To
  207. jump the gun a bit, you can make the cursor move left without erasing
  208. anything by hitting the left (control-l) function key.  Try the following:
  209. insert a few characters, move the cursor left once or twice and insert some
  210. more characters.
  211.  
  212. Overtype mode works just like insert mode except that a character directly
  213. under the cursor is replaced by what you type, instead of moving to the
  214. right.  In other words, in overtype mode you "type over" whatever is
  215. already on the line.  Compare overtype mode to insert mode:  enter overtype
  216. mode, type some characters, move the cursor to the left and type some more
  217. characters.
  218.  
  219.  
  220. Inserting New Lines
  221.  
  222. You can't edit much if you are confined to a single line.  You end one line
  223. and begin another using the insert down (carriage return or control-m)
  224. function key.  Try it.  The insert up (line feed or control-j or insert) function
  225. key is a companion key to the insert down key.  The insert up key inserts a
  226. blank line above the current line.
  227.  
  228. The insert up (line feed or control-j or insert) and insert down (carriage
  229. return) function keys may also cause RED to shift automatically to a
  230. different mode.  Which mode RED shifts to after hitting these keys may be
  231. changed at any time using the def1edit, def1ins and def1over commands.
  232. For example, the def1edit command causes RED to shift automatically to
  233. edit mode whenever the insert down or insert up function key is pressed.
  234.  
  235. Notice that RED will split the line automatically if the cursor reaches the end
  236. of screen while you are inserting characters.  This feature is called line
  237. wrapping.  Try it out.  Notice also that line wrapping never happens if there
  238. are characters to the right of the cursor.
  239.  
  240.  
  241. Moving the Cursor
  242.  
  243. In order to change your text, you must position the cursor near the next to
  244. be changed.  This section tells  you how to do that.
  245.  
  246. The right (control-r) and left (control-l) function keys move the cursor right
  247. or left one column.  However, these keys always leave the cursor on the
  248. same line.  For example, nothing happens if you hit the left key when the
  249. cursor is at the leftmost column of the screen.
  250.  
  251. The up (control-u) and down (control-d) function keys move the cursor up
  252. and down one line respectively.   The cursor will not move above the first
  253. line or below the last line of the file.
  254.  
  255. The up (control-u) and down (control-d) function keys may also cause RED
  256. to shift into a different mode.  Which mode RED will shift to may be
  257. changed at any time using the def2edit, def2ins and def2over commands.
  258. For example, the def2ins command causes RED to shift to insert mode
  259. whenever the up (control-u) or down (control-d) function key is pressed.
  260.  
  261. The page up (control-q or page up) and page down (control-p or page
  262. down) function keys move the cursor up or down one page of the file.  You
  263. need not wait for the screen to be completely redrawn before hitting another
  264. character.
  265.  
  266. The scroll up (control-w) and scroll down (control-o) function keys scroll
  267. the cursor up or down.  Hitting any key interrupts the scrolling.
  268.  
  269. The home (home) key positions the cursor at the start of the top line of the
  270. screen and the end (end) key positions the cursor at the start of the last line
  271. of the screen.
  272.  
  273. The word forward (control-f) and word backward (control-b) function keys
  274. move the cursor forward or backward one word.  A word is any sequence
  275. of characters separated by end-of-line, blank or tabs.
  276.  
  277.  
  278. Deleting Characters and Lines
  279.  
  280. A large part of my writing involves deleting characters and lines:  two
  281. words forward and one word (taken) back--two sentences written and one
  282. erased.  RED lets you do this without any fuss.
  283.  
  284. To delete a single character you must first position the cursor either directly
  285. over the character or just to its right.  The delete left (control-h or
  286. backspace) function key deletes the character to the left of the cursor.
  287. Nothing happens if the cursor is up against the left edge of the screen.  The
  288. delete under (del) function key deletes the character directly under the
  289. cursor.
  290.  
  291. Use the delete line (control-z) function key to delete the entire line on which
  292. the cursor rests.  The screen is redrawn with the line squeezed out.
  293.  
  294.  
  295. Undoing Mistakes
  296.  
  297. Sometimes RED lets us work faster than our thoughts--or maybe our
  298. fingers have a mind of their own.  In any case, there is occasionally a need
  299. for undoing the "improvements" that have just been visited upon a line.
  300.  
  301. The undo (control-x) function key restores a line to what it was when the
  302. cursor last moved to the line.  In other words, the undo function undoes
  303. whatever editing or inserting you have done on the current line.  Several
  304. words of warning:  you cannot use the undo (control-x) function key to
  305. restore a line that has been erased with the erase line (control-z) function
  306. key.  Also, you cannot use the undo (control-x) function key to undo a
  307. change once you have moved the cursor to another line.
  308.  
  309.  
  310. Splitting and Joining Lines
  311.  
  312. Being able to split a line into two pieces or make one line from two is often
  313. very handy. For instance, to edit a line longer than will fit on the screen,
  314. you would first split the line, then make your corrections and finally glue
  315. the line back together again.
  316.  
  317. The split (control-s) function key splits the current line into two pieces.
  318. Everything to the left of the cursor stays right where it is.  All other
  319. characters are moved to a new blank line crated below the original line.  The
  320. split (control-s) function key acts just like the insert down (carriage return)
  321. function key if the cursor is positioned at the right end of the line.
  322.  
  323. The glue (control-g) function key combines two lines into one.  This key
  324. appends the current line to the line above it and then deletes the lower line.
  325. The new line is allowed to be longer than the width of the screen.
  326.  
  327.  
  328. Inserting Control Characters
  329.  
  330. In rare cases, it is desirable to insert control characters into the buffer.  This
  331. requires a special function key.  The verbatim (control-v) function key
  332. enters the next key pressed into the buffer, no matter what it is.  For
  333. example, to insert a control-s into a buffer, type control-v control-s.  After
  334. you press the verbatim (control-v) function key, but before you press the
  335. second key, the prompt line says 'verbatim'.
  336.  
  337.  
  338. Repeating the Previous Function
  339.  
  340. The repeat (control-a) function key repeats the last function key, edit mode
  341. function or escape sequence.  For example, typing control-p control-a is the
  342. same as typing control-p twice.  As we will see, using the repeat key can
  343. sometimes save you typing.
  344.  
  345. The repeat key "amplifies" the effect of several functions as shown in this
  346. table:
  347.  
  348.     original function    amplified function
  349.  
  350.     begin line        home
  351.     end line        end page
  352.     home            page up
  353.     end page        page down
  354.  
  355. For example, typing ESC b ^a ^a is the same as typing ESC b ESC h ^q
  356. because the first ^a amplifies the begin line function (^b) into the home
  357. function (ESC h) and the second ^a amplifies the home function into the
  358. page up function (^q).
  359.  
  360.  
  361. Using Commands
  362.  
  363. Up until now, we have been talking about functions, i.e., operations that
  364. are done by pressing a single function key.  However, functions are not
  365. appropriate in all situations--they might require additional information or
  366. they might potentially alter too much work to be safe.
  367.  
  368. Commands are RED's way of performing complex or dangerous operations
  369. quickly and safely.  You start each command with the enter command
  370. (control-c) function key.  Try this key out now.  Notice that the cursor
  371. moves to the prompt line.  All commands end with a carriage return, and if
  372. you type nothing but a carriage return the command is terminated.  You can
  373. also exit from a command by hitting either the enter edit (control-e), the
  374. enter insert (control-n) or the enter overtype (control-o) function key.  OK,
  375. exit the command in one of the ways just mentioned.
  376.  
  377. If you make a mistake while entering a command, just hit control-h (also
  378. known as backspace) to erase single characters.  You may use either upper
  379. or lower case for commands.
  380.  
  381. At any time, you may change which mode RED will shift to by using the
  382. def0edit, def0ins and def0over commands.  For example, the def0over
  383. command causes RED to shift to overtype mode after each command.
  384.  
  385.  
  386. Creating, Saving and Loading Files
  387.  
  388. After you have finished working on your document you must save it on a
  389. file.  This is a two-step process:  you must name the file and you must
  390. actually save your work to that file.
  391.  
  392. Use the name command to name your file.  Just type "name" (you don't
  393. type the double quotes) followed by the name you want your file to have,
  394. followed (as always) by a carriage return.  Notice that the prompt line
  395. changes to reflect the new file name.
  396.  
  397. Aside:  Your file name can haven o more than eight letters or digits,
  398. followed optionally by a period and no more than three more letters.  The
  399. question mark (?) or star (*) are not allowed in file names.  Examples:
  400.  
  401.     legal names        illegal names
  402.  
  403.     abc            ???.abc
  404.     foo.bar            foo.*
  405.     letter.doc        letter.doc1
  406.     12345678.doc        123456789.doc
  407.     xy.z            x.y.z
  408.  
  409. The last step in creating a new file is writing your work to the file.  If you
  410. don't do this your work will be lost, but don't worry, RED reminds you if
  411. you haven't done so when you try to leave.  To save your work, use the
  412. save command.  While the save command is in progress, the message 
  413. "--saving--" appears on the prompt line.  The save command doesn't take
  414. any arguments;  your work is saved to the file named on the prompt line.  If
  415. you issue the save command when the prompt line indicates "..no file.."
  416. RED complains saying, "file not named".  Hit any key to clear this message
  417. and continue.
  418.  
  419. If RED says "file exists' instead of "--saving--" it means that a file already
  420. exists on the disk with the name shown on the prompt line.  You now have
  421. two choices:  you can pick another name for your file and do the save
  422. command over again or you can use the resave command to replace what is
  423. already on that file with your present work.  (Watch out:  the resave
  424. command destroys the previous contents of the file.)  If you use the resave
  425. command and the file does not already exist, RED gives you the "file not
  426. found" message.  As with the save command, the resave command never
  427. takes any arguments.
  428.  
  429. As mentioned earlier, you can load an already existing file (say memo) at the
  430. same time you start RED by typing 'red memo'.  If RED finds the file on
  431. the disk, RED loads that file and updates the prompt line to indicate the
  432. name of the file.  This is the file name used by the save and resave
  433. commands.  (of course, you can use the name command at any time to
  434. change this name.)  If the file is not found the prompt line says "file not
  435. found".  As always, hit a carriage return to clear this warning message.
  436.  
  437. If you did not give a file name when you started RED, or if you got the "file
  438. not found" message, you can use the load command to load a file into the
  439. buffer.  The load command takes one argument--the name of the file to be
  440. loaded.  As you would expect, the load command changes the file name on
  441. the prompt line so that the save and resave commands will update the file
  442. you just loaded.  Purely as a convenience, RED treats the red command just
  443. like the load command.  Examples:
  444.  
  445.     load abc.doc
  446.     red memo
  447.     save
  448.     resave
  449.  
  450. Unlike some other editors, RED's load command does not create a file if it
  451. does not exist, so you haven't created any unwanted file if you don't get the
  452. name right.  Neither does the load command change the file name on the
  453. prompt line if the file does not exist.  This feature makes the save and resave
  454. commands safe to use in almost all circumstances.  The load command
  455. replaces whatever is in the buffer by the contents of the file being loaded.
  456. For your protection, the load command asks "Buffer not saved, proceed?" if
  457. loading the file might destroy unsaved work.  If you answer 'y' the load
  458. operation begins and whatever is in the buffer is lost.  Otherwise, the load
  459. command terminates and you have an opportunity to save your work.
  460.  
  461.  
  462. Leaving RED
  463.  
  464. There are two ways to leave RED.  The first is the exit command, which
  465. takes no arguments.  For your protection, RED asks "Buffer not saved,
  466. proceed?" if you issue this command before you have saved your work.
  467. Type 'y' to exit anyway or type anything else to cancel the command.
  468.  
  469. The quit command may or may not be available with your version or RED.
  470. If it is available, the quit command works like the exit command (it takes no
  471. arguments), except that RED saves information on your disk so RED can
  472. reload the file you were working on quickly and automatically.  When RED
  473. is next restarted, it looks for this information to resume editing right were
  474. you left off.
  475.  
  476. The quit command is nice to have if you do a lot of work with a single file
  477. because it saves 99% of the time it takes to load a file with the load
  478. command.  However, the quit command does have some drawbacks.
  479. First, the saved information (the work file) takes up space on the disk when
  480. RED is not being used.  Second, if the work file is erased, some of your
  481. work may be lost.  Third, if you interrupt RED by hitting your computer's
  482. reset key, the work file will not have the proper file status line.  The next
  483. time you start RED, RED will complain and you should erase the work file
  484. by hand.
  485.  
  486.  
  487. Searching for Patterns
  488.  
  489. As your file becomes longer and longer, it becomes harder and harder to
  490. find the parts of it that you want to change.  Instead of searching for words
  491. or phrases yourself, RED can do the searching for you.
  492.  
  493. In order to do searching, you must specify patterns which tell RED what to
  494. look for.  A pattern is simply any string of characters ended by a carriage
  495. return.  Most letters in patterns just stand for themselves:  Examples:
  496.  
  497. o The pattern 'abc' matches the three letters 'a' 'b' and 'c'
  498. o The pattern '12-4' matches the four characters '1' '2' '-' and '4'
  499.  
  500. There are three characters which have special meanings within patterns and
  501. make patterns more powerful.  A question mark in a pattern matches any
  502. character at all.  Examples:
  503.  
  504. o The pattern '?bc' matches any 'bc' that is not the first character on a line.
  505. o The pattern 'a?c' matches an 'a' and 'c' with exactly one character between
  506. them.
  507. o The pattern '???' matches any three characters on the same line.
  508.  
  509. A leading caret ('^'), i.e., a caret that appears at the start of a pattern, matches the start of a line.  Examples:
  510.  
  511. o The pattern '^abc' matches any line that starts with 'abc'.
  512. o The pattern '^??abc' matches any line with 'abc' starting in column 3.
  513.  
  514. A caret that does not start a pattern loses its special meaning.  Examples:
  515.  
  516. o The pattern '^?^a' matches any line with a '^' in column 2 followed by an 'a'.
  517. o The pattern '?^' matches any '^' which is not in column 1.
  518.  
  519. A trailing dollar sign, i.e., a dollar sign that appears at the end of a pattern,
  520. matches the end of a line.  Examples:
  521.  
  522. o The pattern 'abc$' matches any line that ends with 'abc'.
  523. o The pattern 'abc??$' matches any line with exactly two characters after 'abc'>
  524.  
  525. A dollar sign that does not conclude a pattern loses its special meaning.
  526. Example:
  527.  
  528. o The pattern '^?$?' matches any line with '$' in column 2 followed by
  529. some other character.
  530.  
  531. A leading caret and trailing dollar sign may be used in the same pattern.
  532.  
  533. Examples:
  534.  
  535. o The pattern '^abc$' matches any line that contains only 'abc'.
  536. o The pattern '^?$' matches any line with exactly one character.
  537.  
  538. The find command puts the cursor at the start of the pattern when the pattern
  539. is found.  You invoke the find command as you would expect:  type the
  540. enter command (control-c) function key followed by find <CR>.  The
  541. prompt line will now ask you for a search mask.  This means that you
  542. should enter a pattern to search for.  Type in the pattern and end it with a
  543. carriage return.
  544.  
  545. The find command will now search from the place where the cursor is,
  546. looking for the pattern.  If the find command reaches the end of the buffer
  547. without finding a match the search "wraps around the buffer," i.e., the
  548. search continues form the start of the buffer to the line where the search
  549. originally commenced.  If the find command eventually matches the pattern,
  550. RED will place the cursor at the start of the pattern. If no match is found,
  551. RED will simply put the cursor back where it was before the find command
  552. was invoked.
  553.  
  554. The findr command works just like the find command except that it searches
  555. backwards through the buffer for a pattern.
  556.  
  557. The search command searches for a pattern just like the find command, but
  558. the search may be continued after a pattern is found.  When a match is
  559. found, the prompt line will say, "next, exit?".  If you hit an 'n', the search
  560. will continue.  The search will end if you hit any other key.
  561.  
  562. The change command searches for  a pattern in a manner similar to the
  563. search command, but when a match is found a substitution is made.  When
  564. you invoke the change command, you will be asked for a search mask, just
  565. as with the search command.  Next, you will be asked for a change mask.
  566. Whenever the pattern specified by the search mask is found, the pattern
  567. specified by the change mask is substituted.
  568.  
  569. Carets and dollar signs have no special significance in a change mask.
  570. Question marks in a change mask are replaced by the character that matched
  571. the corresponding question mark in the search mask.
  572.  
  573. For example, suppose the search mask is 'a?b?' and the change mask is
  574. 'A??C'.  If the characters that match the search mask are 'a+b-' would be
  575. replaced by 'A+-C' because the two question marks in the change mask
  576. would be replaced by '+' and '-' respectively.
  577.  
  578. The change command does not make all changes in the buffer at once.
  579. When a match the substitution is made on the screen and the prompt line
  580. asks,
  581.  
  582.     "yes, no, all, exit?"
  583.  
  584. The substitution is undone if you reply 'n' or 'e' and the change command
  585. terminates if you say'e'.  If you reply 'y', the change is made and the
  586. searching continues.  If you say 'a', the change is made and searching
  587. continues.  However, when you say 'a', all changes are made without
  588. further prompting and no further changes are shown on the screen.  Only
  589. the line number field on the prompt line shows that changes are being
  590. made.
  591.  
  592. The find and findr commands start searching from the current line, but you
  593. can change that by invoking these commands with a line number.
  594.  
  595. Examples:
  596.  
  597.     command    search starts at
  598.  
  599.     find        current line
  600.     find 1        line 1
  601.     findr 9999    end of buffer
  602.  
  603. The change and search commands look through the entire buffer for the
  604. pattern unless you specify a portion of the buffer to search.
  605.  
  606. Examples:
  607.  
  608.     command        what is searched
  609.  
  610.     search        every line
  611.     search 1 9999    every line
  612.     change 70 90    lines 70--90
  613.     search 50    lines 50--end
  614.     change 90 9999    lines 90--end
  615.  
  616.  
  617. Moving Blocks of Lines
  618.  
  619. One of the most common editing operations is cutting and pasting.  RED
  620. has four commands that make this easy.
  621.  
  622. The move command moves a block of lines from one place in the buffer to
  623. another.  The move command takes three arguments, the first line to move,
  624. the last line to move, and the line after which the lines are to be moved.
  625. Only one line is moved if only two line numbers are given.
  626.  
  627. Examples:
  628.  
  629.     command        line(s) moved        where moved
  630.  
  631.     move 1 2 3     1--2            after line 1
  632.     move 1 2 0    1--2            before line 1
  633.     move 2 10    2            after line 10
  634.  
  635. The copy command works just line the move command except that a copy
  636. of the lines is moved so that the original lines stay where they were.
  637.  
  638. Examples:
  639.  
  640.     command        line(s) copied        where copied
  641.  
  642.     copy 1 2 3     1--3            after line 3
  643.     copy 1 2 0    1--2            before line 1
  644.     copy 1 8    2            after line 8
  645.  
  646. The extract command copies a block of lines to a file without erasing the
  647. block from the buffer.  Take care with this command:  the file is erased if it
  648. already exists.  Another caution:  integers are legal file names, so make sure
  649. you include the file name.  Examples:
  650.  
  651.     command           file name    lines written
  652.  
  653.     extract abc       abc        whole file
  654.     extract 1 2       1        line 2
  655.     extract abc 1 2       abc        lines 1--2
  656.     extract f 1 999       f        whole file
  657.  
  658. The inject command is the companion to the extract command.  The inject
  659. command adds a file to the buffer.  It does not replace the buffer as does the
  660. load command.
  661.  
  662. Examples:
  663.  
  664.     command           where injected
  665.  
  666.     inject abc       after current line
  667.     inject abc 0       before line 1
  668.     inject abc 9999       at end of file
  669.     inject abc 50       after line 50
  670.  
  671. You can use the extract and inject commands to cut and paste between
  672. different files.  Extract a block of lines from the first file into a temporary
  673. file, load the second file and then inject the lines from the temporary file into
  674. the second file.
  675.  
  676.  
  677. Setting Tab Stops
  678.  
  679. Tab stops effect how tabs are shown on the screen and printed on the
  680. printer.  RED sets tab stops every 8 columns to begin with, but this can be
  681. changed with the tabs command.  After this command the screen is redrawn
  682. so you can see the results of the new tab setting.  Examples:
  683.  
  684.     command        width of tabs
  685.  
  686.     tabs        8
  687.     tabs 8        8
  688.     tabs 4        4
  689.  
  690.  
  691. Enabling and Disabling Line Wrapping
  692.  
  693. Initially, line wrapping is enabled.  Lines are split whenever
  694.  
  695. a) the cursor is the last character of the line and
  696. b) the cursor is at the right edge of the screen and
  697. c) a character is inserted.
  698.  
  699. The nowrap command disables line wrapping.  When line wrapping is
  700. disabled, no further insertions are allowed in a line when the cursor reaches
  701. the right margin of the screen.  If you want to enable line wrapping again
  702. after using the nowrap command, use the wrap command.
  703.  
  704.  
  705. Listing the Buffer
  706.  
  707. The list command prints the buffer on your printer.  Lines are formatted just
  708. as they are on the screen, but the length of the print line, not the width of the
  709. screen, determines where long lines are truncated.  You can interrupt the
  710. listing at any time by hitting any control key.
  711. Examples:
  712.  
  713.     command        what is listed
  714.  
  715.     list        the current line
  716.     list 15        line 15
  717.     list 1 9999    the entire buffer
  718.     list 400 500    lines 400--500
  719.  
  720.  
  721. Deleting Multiple Lines
  722.  
  723. The clear command erases the whole buffer, while the delete command
  724. deletes one or more lines.  The clear command will caution you if erasing
  725. the buffer might cause work to be lost, but the delete command does not, so
  726. be careful.  Examples:
  727.  
  728.     command        what is deleted
  729.  
  730.     clear        the whole file
  731.     delete 1 9999    the whole file
  732.     delete        the current line
  733.     delete 25    line 25
  734.  
  735.  
  736. Choosing How RED Switches Modes
  737.  
  738. As mentioned before, RED will automatically switch from one mode to
  739. another in three situations:
  740.  
  741. 1) after every command
  742. 2) after inserting new lines and
  743. 3) whenever the cursor moves up or down one line.
  744.  
  745. You can choose exactly what RED will do in each case.  This section tells
  746. how.
  747.  
  748. The def0edit, def0ins and def0over commands determine which mode (edit,
  749. insert or overtype) RED will be in after each command.  For example, after
  750. the def0edit command is given, RED will switch to edit mode after each
  751. command.
  752.  
  753. The def1edit, def1ins and def1over commands determine which mode RED
  754. will be in after the insert up (line feed) or insert down (carriage return)
  755. function keys are pressed.  For example, after the def1ins command is
  756. given, RED will switch to insert mode whenever a new blank line is
  757. created.
  758.  
  759. The def2edit, def2ins and def2over commands determine which mode RED
  760. will be in after the up (control-u) or down (control-d) function keys are
  761. pressed.  For example, after the def2over command is given, RED will
  762. switch to overtype mode whenever the up or down function keys are pressed.
  763.  
  764.  
  765. Edit Mode Functions and Escape Sequences
  766.  
  767. Edit mode lets you avoid typing so many control keys.  In edit mode, typing
  768. regular (i.e., non-control) keys makes RED act as though function keys
  769. were pressed.  Some people find using normal characters in this way
  770. confusing, which is why this section has been left until now.  Other people,
  771. myself for instance, think that edit mode is a great convenience.
  772.  
  773. Escape sequences are an added frill; they are a way of executing edit mode
  774. functions without switching to edit mode.  Escape sequences consist of the
  775. escape (ESC) function key followed by an edit mode function.  For
  776. example, the 'h' edit mode function homes the cursor to the top left corner
  777. of the screen.  If RED were in insert mode I could home the cursor using
  778. the ESC h escape sequence without having to switch RED to edit mode
  779. first.  By the way, edit mode commands and escape sequences may be
  780. typed either in upper case or in lower case.
  781.  
  782. Here is a list of the edit mode functions.  For simplicity's sake the functions
  783. are listed in alphabetical order.  Again, each function may be used outside of
  784. edit mode by using an escape sequence.
  785.  
  786. The space bar moves the cursor right one column.  Nothing happens if the
  787. cursor is up against the right edge of the screen.  In other words, the space
  788. bar works exactly the same as the right (control-r) function key.
  789.  
  790. The '+' key moves the cursor down a half a page.  The '-' key moves the
  791. cursor up a half page.
  792.  
  793. The b key puts the cursor at the beginning (left hand edge) of the line.  This
  794. key is amplified by the repeat key into the home function.  For example,
  795. typing b ^a in edit mode is the same as typing b p.  Similarly, typing ESC b
  796. ^a in insert mode is the same as typing ESC b ESC p.
  797.  
  798. The d key causes the cursor to move down rapidly.  Type any key to stop
  799. the scrolling.
  800.  
  801. The e key moves the cursor to the right end of the line.  This key is
  802. amplified by the repeat key into the end page function.  For example, typing
  803. e ^a in edit mode does the same thing as typing e q.  Similarly, typing ESC
  804. e ^a is the same as typing ESC e ESC z.
  805.  
  806. The g key moves the cursor to another line.  After you type the g the cursor
  807. will move to the prompt line.  The prompt line will show 'goto:'  Now type
  808. a line number followed by a carriage return.  By the way, there is a g
  809. command that works the same way.
  810.  
  811. The h key homes the cursor to the top left corner of the screen.  This key is
  812. amplified by the repeat key into the page up function.  Thus, typing h ^a in
  813. edit mode is the same as typing h q.  Similarly, typing ESC h ^a works the
  814. same as typing ESC h ESC q.
  815.  
  816. The k key deletes all characters from the cursor up to but not including the
  817. word that starts with a "search character".  Everything from the cursor to the
  818. end of the line is deleted if no word starts with the search character.  After
  819. you hit the k the prompt line displays 'kill'.  Now type the search character.
  820. If you wish to cancel the k command before specifying the search character,
  821. press any control character.  The k command will be stopped and no
  822. deletion will be made.  If too much text is deleted, use the undo key and try
  823. again.  Example:  Typing k <space> deletes the following word.
  824.  
  825. The m key moves the cursor to the start of the line in the middle of the
  826. screen.
  827.  
  828. The p key moves the cursor down one page.  You don't have to wait for the
  829. screen to be completely redrawn before you hit another key.  Thus, hitting
  830. several p keys is a very fast way to move short distances.  The q key is the
  831. companion to the p key.  It moves the cursor up one page.
  832.  
  833. The s key moves the cursor to the next word that starts with a search
  834. character.  If no word starts with a search character.  If no word starts with
  835. the search character the cursor is moved to the end of the current line.  After
  836. you hit the s key, the prompt line displays 'search'.  Now type the search
  837. character.  Example:  Typing s <space> moves the cursor right one word.
  838.  
  839. The u key moves the cursor up rapidly.  You stop the scrolling by typing
  840. any key.
  841.  
  842. The x key replaces the character under the cursor.  After you type the x
  843. command the prompt line displays 'eXchange'.  Now type the new
  844. character.  If you hit a control character no change is made and the x
  845. command is canceled.
  846.  
  847. The z key moves the cursor to the start of the last line on the screen.  This
  848. key is amplified by the repeat key into the screen down function.  For
  849. example, typing z ^a in edit mode is the same as typing z p.  Similarly,
  850. typing ESC z ^a is the same as typing ESC z ESC p.
  851.  
  852.  
  853. What To Do About Error Messages
  854.  
  855. RED will print a message on the prompt line should anything go amiss.
  856. You clear the message by hitting any key.  Usually the message will be a
  857. reminder about how to enter a command.  For example, if you forget how
  858. to use the move command, just do the move command anyway.  RED will
  859. say, 
  860.  
  861.     usage:  move <block> <n>
  862.  
  863. This may jog your memory enough so you won't have to look up the
  864. command in this chapter.
  865.  
  866. The only serious error you might see is:
  867.  
  868.     write error:  disk or directory full??
  869.  
  870. This error usually means that RED could not complete a save or resave
  871. command because there was not enough room on the disk.  This error is not
  872. too serious; you should be able to recover from this error if you do a save or
  873. resave to another disk.  But you should never remove the disk from which you invoked RED!  (That disk contains the work file, which is what you are
  874. trying to save.)
  875.  
  876. More rarely you can see this error when you are making insertions into the
  877. buffer.  When this happens, try to save the buffer to a new file on another
  878. disk.  Once again, do not remove the disk from which you invoked RED!
  879. This may or may not work, depending on whether another disk is available
  880. Thus, you may lose the work you have done since your last save or resave.
  881. Obviously this is not a pleasant occurrence.  You can avoid this problem by
  882. making sure that your disk has enough room to hold your work and by
  883. frequently saving your work.
  884.