|
SECTION 4 CREATING AND EDITING TEXT TEXT EDITING COMMANDS After logging in and becoming familiar with the basic Multics environment, you will probably want to create and edit information on Multics. Multics has several text editors, powerful interactive commands that enable you to create, edit, and store your own segments. The two primary text editors on Multics are commands named qedx (short name "qx") and emacs. The qedx editor is a line-oriented editor; that is, you may make changes to one or more lines of text on a line by line basis. It is designed to be used on a printing terminal. There are two modes of operation in qedx: an input mode for entering new text, and an edit mode. The emacs editor is a character-oriented editor designed for video terminals. In emacs, no distinction is made between edit and input modes - you are free to edit as you type in text. This section is a very brief introduction to both qedx and emacs. It describes the fundamentals of the commands and provides you with some of their most useful requests. However, the qedx and emacs editors have user guides that explain them fully: the emacs Text Editor Users' Guide, and the qedx Text Editor Users' Guide. One of these manuals should be among your group of essential Multics manuals. THE qedx EDITOR - PRINTING TERMINALS There are two modes of operation in qedx: an input mode for entering new text, and an edit mode. In input mode, you type information into the system; that is, you create text. In edit mode, you make changes to already existing text. A set of qedx requests allows you to enter and leave input mode, perform the various editing functions (substitution, deletion, printing), and save your text in segments. Creating Text To enter the qedx editor, you type the qedx command, "qedx" (or "qx"), and a newline. Now you are in edit mode; notice that there is no prompt to remind you of this. In edit mode, qedx expects requests from you. To enter input mode and create text, type "a" - the append request - and then a newline. Now you type in your text. The erase and kill characters still perform their correcting functions within input mode. The characters "\f" together (backslash-f) at the beginning of a line end your input session and return you to edit mode. Here is an example of creating text:
Be sure to type the "\f" as soon as you want to stop creating text. Until you type "\f", EVERYTHING you type is included as part of your text, including any requests you type thinking that you have already left input mode! So, if qedx does not respond to your editing requests, try typing "\f". When this occurs, you will probably need to delete several lines of editing requests from your text. Editing Text The qedx editor treats text as a series of numbered lines, the top line being line 1. The editor also renumbers the text every time lines are added or deleted. For example, if you delete line 1 of your text, then line 2 becomes line 1, and line 3 becomes line 2. Because the number of lines in your text changes often, the "$" character has been established to stand for the the last line, no matter what its number is. These line numbers are implied - they do NOT appear next to your text. Within the editor is an implicit "current line pointer", which is always "pointing at" one line of your text — the last line you typed in or edited. The "=" (equal) request prints the line number of the current line, that is, where the current line pointer is located at the moment. Another method of locating lines of text moves the current line pointer to the line you request and then prints that line. This method consists only of an address: either an absolute line number ("2", "$"), a relative line number (relative to the current line: "-1", "+3"), a character string between slashes ("/Br/"), or a period, which always prints the current line. For example:
There is no letter associated with this method of finding lines. Addresses are often used in conjunction with editing requests to specify on which lines changes are to be made. The request can be preceded by one address, as in this example using the "d" (delete) request to delete the line:
or it can be preceded by two addresses with a comma between (but no spaces), as in this example using the "p" (print) request:
Using two addresses with a request means that the request operates on the first line THROUGH the last line addressed. It is a good idea to use the "p" request often, to make sure that you are doing what you intended. To modify words within lines, use the "s" (substitute) request preceded by one or two addresses. The "s" request expects to be followed by two character strings separated by slashes (FORWARD slashes - not the backslash of the "\f" request!) telling it the old string and the new string:
If you wanted to change the word "and" to the word "And" on the third line, you might type:
Be careful, though - an "s" request makes this change on ALL instances of the character string you supply, on the line or lines you specify. If there is a mistake, you can use the "s" request to fix it:
The default value for the "d", "p", and "s" requests is the current line. Saving Text When you are in the qedx editor (in either mode), the text you enter is kept in a temporary space called a buffer, All your work in this buffer is discarded when you leave qedx and return to command level (with the quit request, "q"). In order to save your work in a segment, you must use the "w" (write) request, along with a name you choose, to write a copy of your work from the buffer into a segment with the name you have provided:
Now you have a permanent segment named "Doggerel". Remember: unless you type a "w" and the name of the segment, your work is not saved. When naming your segments, keep in mind that you should use only alphabetic and numeric characters, underscores (rather than spaces), periods, and hyphens. Names can be up to 32 characters long. Remember also that uppercase characters are distinguished from lowercase characters. When you want to return to qedx and edit an already existing segment, for example the "tadpole" segment, you must "read" a COPY of it into the editor at the beginning of your editing session. Do this at qedx request level by typing the "r" (read) request, followed by the name of your segment:
Before you do this, the buffer is empty. Now it contains a copy of the segment "tadpole". Check the qedx Text Editor Users' Guide for any questions you may have. It describes all aspects of the qedx editor in complete detail. THE emacs EDITOR - VIDEO TERMINALS The emacs editor is designed especially for use at a video terminal. It is a character-oriented editor: the cursor of the terminal (the blinking underscore or square) acts as a visible pointer to one character at a time. Text is entered simply by typing. Changes can be made at any time, by typing requests that move the cursor to the point desired and then adding or deleting as you wish. A limited set of requests is described below. Creating Text To enter the emacs editor, you type the emacs command and a newline. Your screen clears, and you are at request level, in Emacs Fundamental mode; a banner announcing this, called the mode line, is displayed now at the bottom of your screen. The space above displays the contents of the buffer (the temporary workspace for text entry and editing) and is called a window. Below the mode line is a space called the minibuffer; messages from emacs, and your replies, are displayed here, so as not to interfere with your text. Here is a diagram illustrating a video screen after you've entered emacs:
To enter text, you simply type, as you would on a typewriter. Your text appears on the screen a few seconds after you enter it; type a carriage return whenever you want to start a new line. The lines displayed in the window are EXACTLY what your text contains. You may erase characters and kill lines as you normally do on Multics, and then type in the correct text. Notice that while you work with emacs, the erase and kill characters actually cause the deleted material to disappear from your screen, emacs Requests You have a whole array of emacs requests for moving the cursor to the point where a correction is needed. The two types of requests introduced here are control characters and escape characters. A control character, for instance a "control P", is executed with the key labeled CTL or CONTROL. You use it like the shift key, so that for a "control P" you hold down the CTL key WHILE typing an uppercase or lowercase P. A control character is expressed by a carat (^) followed by the appropriate character: ^P for "control P". Escape characters use the key labeled ESC, ESCAPE, ALT, or ALTMODE on your terminal. Do not hold this key down while you type its associated character - type ESC and release it, and THEN type the next character. An escape character is expressed by the letters ESC followed by the appropriate character: ESC V for "escape V". Editing Text In order to change some text already entered, you need to know how to position the cursor. Here is a short list of requests that move the cursor through the lines of your text. These requests operate even if the affected lines are not currently on display in the window (the window displays only about 20 lines of your text at a time).
moves the cursor to the previous line, trying to stay in the same column.
moves the cursor to the next line, trying to stay in the column.
displays the next screenful of text in this buffer, leaving the cursor at the top of the screen.
displays the previous screenful of text (one back) in this buffer, leaving the cursor at the top of the screen.
moves to the first line of text in the buffer, leaving the cursor in front of the first character.
moves to the last line of text in the buffer, leaving the cursor just after the last character. The following requests are useful for moving the cursor within one line:
moves the cursor forward a character at a time.
moves the cursor backward a character at a time.
moves the cursor forward a word at a time.
moves the cursor backward a word at a time.
moves the cursor in front of the beginning of a line.
moves the cursor to just after the last character of a line. Once you reach the right place, you can use either the erase and kill characters or one of the following deletion requests:
delete the character at the cursor.
delete the word at and forward (to the right) of the cursor.
delete from the cursor to the end of that line; when at an empty line, delete that. When you type any of these requests, the deleted text disappears from your screen, and surrounding text closes up the space. The cursor remains, and you just type in any text you'd like to add. The surrounding text moves aside as you type. Saving Text As noted above, when you are in the emacs editor, the text you enter is kept in a temporary space called a buffer. All your work in this buffer is discarded when you leave emacs and return to command level. In order to save your work on emacs, you must issue the "write-file" request, ^X^W, to copy your text into a segment with a name you have provided. After typing ^X^W, a message in the minibuffer prompts you for the pathname of the segment into which you want to "write", or copy, your buffer's contents. (Whenever emacs prompts you, the cursor moves into the minibuffer so you can type your reply there without interfering with your previous work.) Type the pathname and a carriage return. Now a permanent segment is created with the contents of your buffer, and the cursor returns to its previous position in your text. Note that the pathname appears in the minibuffer. At this point you can continue adding text if you want, and repeat this request later, or you can leave the editor. To leave emacs, you type the "quit-the-editor" request, ^X^C. If you have typed new text into your buffer, or changed it in any way without writing it out, emacs asks you if you really want to quit. You have to respond "yes" if you do. If you did write your buffer out, you are immediately returned to command level. When you want to return to emacs and edit an already existing segment, for example the "tadpole" segment, you must place a COPY of the segment into the editor's buffer at the beginning of your editing session. Do this at emacs request level by typing the "find-file" request, ^X^P, which will prompt for the name of the segment to be edited. After the segment is read in and displayed in the window, the cursor is left at the beginning of the buffer. Since your screen is small, it does not always display your whole buffer, but it is there, nevertheless. Getting Help From Emacs The emacs editor has an extensive online documentation system that can provide information about any request, tell you what any request does, tell you what requests you gave recently, or help you determine what request is needed for a specific task. To find out what any given key or control character does, type ESC ? and then the key or control character you have questions about. All other help requests center around the emacs "help" request, ^_ (control-underscore). (On some terminals, ^? performs this function; if one doesn't work, try the other). The help request may be your most useful request, as you begin experimenting with emacs. Type "^_?" to find out more about what help facilities are available. Use the "LINEFEED" or "LF" key to remove the displays produced by these requests. If your terminal has an automatic line feed, you may need to turn off this feature to prevent these displays from vanishing from your screen as soon as they appear. See the emacs Text Editor Users' Guide for any questions you may have. It describes, in tutorial style, all aspects of the emacs editor.
<< Previous Section Next Section >> Contents | 1 | 2 | 3 | 4 | 5 | 6 | 7 | A | B
|