1                    An Introduction to Using Multics Emacs  10/27/79
   2 
   3 **This file is intended to be perused via dprint, print, or via an**
   4 **editor.  It is not intended to be perused with the help command **
   5 
   6 
   7 
   8 
   9 
  10 ^L
  11 Multics Emacs is an integrated editing, text-preparation, and screen
  12 management system designed to take advantage of the features of modern display
  13 terminals to aid in interactive text entry and editing.  In some sense, it is
  14 an editor: yet a more appropriate description would be a "text processing
  15 subsystem": continuous interaction with text is its mode of operation, not
  16 "editing" via carefully structured "editing requests".
  17 
  18      Although it is possible, and valuable, to use Multics Emacs from a
  19 "printing terminal", i.e., one that uses paper and ink, it is oriented
  20 towards video terminals, and its usage is best learned on a video terminal,
  21 preferably at 1200 baud or better.
  22 
  23      Sit down at a video terminal logged into Multics.  Invoke Emacs
  24 by typing its name at the command processor:
  25 
  26      emacs
  27 
  28 Depending upon the facilities available at your site, Emacs may or may not
  29 ask you:
  30 
  31      What type terminal do you have?
  32 
  33 
  34 If Emacs poses this question, which it will only ask you once per login
  35 session, as opposed to clearing the screen, type in the name of the type of
  36 terminal that you have.  If you do not know this, ask your Site Support
  37 personnel.  If you type a bad name, Emacs will type out the names of all
  38 terminals it knows how to support, so that you can type the right name.  Or
  39 type "quit" to give up.  Terminate the name of the terminal with a
  40 carriage-return, as you would any Multics input.
  41 
  42      Now Emacs will take several seconds to get started up; it has a lot to
  43 do at start-up time.  When it has started up, it will clear the screen, and
  44 display the line
  45 
  46      Emacs (Fundamental) - main
  47 
  48 at the lower left of the screen.  This line is called the _^Hm_^Ho_^Hd_^He _^Hl_^Hi_^Hn_^He.
  49 It tells you several things, most important of which is that you are talking to
  50 Emacs, as opposed to the command processor, or some other editor.
  51 "Fundamental" is called the _^Hm_^Ho_^Hd_^He.  There are various _^Hm_^Ho_^Hd_^He_^Hs
  52 best suited to preparing text, programs in different languages, and other
  53 tasks.  Fundamental mode is the first and simplest mode.  It has no
  54 specialized features at all.  "main" is the _^Hb_^Hu_^Hf_^Hf_^He_^Hr _^Hn_^Ha_^Hm_^He.  You can be editing
  55 many things at once with Emacs, like qedx.  Each separate thing being edited
  56 is edited in a separate "sub-editor" called a _^Hb_^Hu_^Hf_^Hf_^He_^Hr. The buffers have names;
  57 "main" is the name of the buffer you start out in.
  58 
  59      The region between the top of the screen and the mode line is where text
  60 appears, and where we deal with text.  This area of the screen is called the
  61 _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw.  It will always display 20 or so consecutive lines of the document or
  62 program you are editing.  The region below the mode line has two areas,
  63 the _^Hp_^Ha_^Ht_^Hh _^Hl_^Hi_^Hn_^He and the _^Hm_^Hi_^Hn_^Hi_^Hb_^Hu_^Hf_^Hf_^He_^Hr, which we will deal with
  64 later.
  65 
  66      You will note the blinking _^Hc_^Hu_^Hr_^Hs_^Ho_^Hr in the upper-left-hand corner
  67 of the screen.  The cursor may be a blinking underline on some terminals, or
  68 a blinking or solid box on others.  The cursor is always on some position on
  69 the screen.   The cursor is the single most important object in Emacs:
  70 we must familiarize ourselves with it, and must always concern ourselves with
  71 its whereabouts on the screen.  All "action" happens at the cursor: all text
  72 we enter is entered "at" the cursor (and the cursor moves), and text we delete
  73 is deleted at the cursor, as well.
  74 
  75      Now we are going to enter some text.  We do not have to tell Emacs that
  76 we are going to type.  There is no "input mode" or "edit mode": we just type.
  77 Type these words on the terminal, do _^Hn_^Ho_^Ht end it with a carriage return, line
  78 feed or other special character, the period should be the last character you
  79 type:
  80 
  81      This is sample text.
  82 
  83 You will note that you do not see what you have typed immediately, but
  84 soon after you start typing, the text on the screen will "catch up" with you.
  85 This is because you have waited a few minutes since the last time you typed,
  86 and Multics has "forgotten" about you temporarily.  In general, you may see
  87 what you type as soon as you type it, or sometimes a little later, depending
  88 on the load on Multics.  This is very different than other Multics programs;
  89 other programs rely on the terminal to type out what you type in, but Emacs
  90 must type it out for you.
  91 
  92      You will also note a little star come on under the word "Emacs": this
  93 is called the "modified" star.  When it is there, it means that the
  94 text in your buffer is different than the text you read in, if any, or
  95 is new text (as is the case here), and hasn't been written out to a file.
  96 When the "modified" star is on, you know that you wil have to write your text
  97 out before exiting Emacs.
  98 
  99      You will see the text you typed at the top of the screen.  It just
 100 appeared there as you typed it.  You did not have to issue a "print request":
 101 The line you are looking at at the top of the screen is the beginning of your
 102 document: you are looking at your document, not an "input line", or an
 103 "output line" or a "printout".  At all times, you are looking at your
 104 document.
 105 
 106      Look at the screen. You will see the cursor to the right of the period
 107 in the sentence "This is sample text".  You should begin to think "We are
 108 to the right of the period on that line."  At all times, the person using
 109 Emacs must think of himself or herself "at" some point in his or her document,
 110 that "point" being indicated on the screen by the cursor.
 111 
 112      Now let us add another line.  Type the "carriage return" key on your
 113 terminal to end this line and start another one.  "Carriage return" is a
 114 character, just like "T", "h", "i", or "s", or a space.  Typing it will
 115 put a "carriage return" character into your text, and move the cursor to
 116 _^Hb_^He_^Hy_^Ho_^Hn_^Hd the carriage-return character, which is to say, the beginning of the
 117 next line.   Having entered the carriage return, type:
 118 
 119      Here is more text yet.
 120 
 121 Again, the text appears on the screen as we type it.  The line we had typed
 122 earlier stays where it is, we now have a two-line document.  Using what we
 123 know already, we can type in a whole document!  It is just like using a
 124 typewriter.
 125 
 126      This is fine, until we make an error.  We have to fix errors as we note
 127 them.  Let us type a line with an error in it on purpose.  Go to the next
 128 line, by typing a carriage return, and type:
 129 
 130 Multix
 131 
 132 
 133 We have made an error.  The "x" in "Multics" should have been a "cs".  What
 134 do we normally do in Multics if we type a wrong letter?  We use #, the _^He_^Hr_^Ha_^Hs_^He
 135 _^Hc_^Hh_^Ha_^Hr_^Ha_^Hc_^Ht_^He_^Hr.  The same is true in Emacs, but watch what happens.  Type the "#"
 136 (pound sign, or number sign) character.  Observe that the "x" in "Multix"
 137 physically disappears off the screen, leaving no trace of itself or the pound
 138 sign!  The character has been erased; our document is on the screen.  The "x"
 139 is no longer in our document.  What is more, there is no trace or record of
 140 the mistake we made, or what we did to correct it.  The document is correct
 141 on the screen, as always.  Now, to put in the c and the s, just type the c
 142 and type the s, and the word "Multics" will appear correct.
 143 
 144      We can continue in this fashion, entering text just by typing it, ending
 145 lines with carriage returns when we want to go on to the next line, until our
 146 whole document is entered, correcting mistakes with #, but soon we may find
 147 a need to change, or modify, some text we had already entered.  For example,
 148 let us change the line we entered that said:
 149 
 150      This is sample text.
 151 
 152 to say:
 153 
 154      This is some sample text.
 155 
 156 adding the word "some" after the word "is".  The way we do this in Emacs is to
 157 "go" to the place in the text after the word "is", to _^Hm_^Ho_^Hv_^He or _^Hp_^Ho_^Hs_^Hi_^Ht_^Hi_^Ho_^Hn
 158 ourselves there, by moving the cursor there.  We want to go up two lines and
 159 over a few characters.  First, let us "get to" the right line.  We will go there
 160 one line at a time.  We will tell Emacs "Go to the previous line".
 161 
 162      Look on your keyboard for a key labelled "CTL", "CTRL", "CONTROL",
 163 "CNTRL", or the like.  This is a very important key for Emacs; it is called the
 164 _^Hc_^Ho_^Hn_^Ht_^Hr_^Ho_^Hl key.  It is like a shift key: you hold it down, and while holding it
 165 down, you type one or more normal characters.  Like a shift key, pressing it
 166 and releasing it has no effect.  When you press the "p" key (DON'T do it now),
 167 you get a lower-case "P".  If you press the "p" key while holding the "SHIFT"
 168 key, you get an upper-case "P".  If you press the "p" key while holding the
 169 "CONTROL" key, you get something called a "Control P".  It is a different
 170 _^Hv_^Ha_^Hr_^Hi_^He_^Ht_^Hy of P, just like p and P, except instead of being an upper case
 171 letter or a lower case letter, it is a called a "control character". All
 172 control characters are commands to Emacs.  You have seen what happens
 173 when you type normal upper and lower case characters; they go into the
 174 document.  Control characters are used to control Emacs, to manipulate the
 175 cursor and manipulate text.
 176 
 177      To make Emacs move the cursor to the P^H_revious line, we use the control
 178 character "Control P", the P^H_ being for P^H__^Hr_^He_^Hv_^Hi_^Ho_^Hu_^Hs. Do so: hold down the
 179 "CONTROL" key, like a shift key, and press the "P" key, while still holding
 180 the "CONTROL" key, then release both. Now watch the screen: you will observe
 181 that the cursor will indeed move up to the previous line, to a place right
 182 above where it had been.  This happens as soon as we type the Control P,
 183 we do not have to type (and must not type!) a carriage-return or other
 184 character to make it happen.  Note also that when we type Control P,
 185 we do not "see" our command anyplace on the screen, all we see is what it did.
 186 This is a very important principle in Emacs: what you see on the screen is
 187 what you have in your document, and it does not matter what you used to
 188 achieve that state.
 189 
 190      Now let us go up one more line, to the first line. Hold down the control
 191 key again, and press "P" while holding it.  Again, the cursor will jump up
 192 a line.
 193 
 194      Now that we are on the correct line for the change we wish to make, we can
 195 move around on that line to get to the correct place.  We can move
 196 _^Hb_^Ha_^Hc_^Hk_^Hw_^Ha_^Hr_^Hd_^Hs on that line by telling Emacs to "go backwards": as you guessed,
 197 this is done with a "Control B", B^H_ for B^H_ackwards.  Hold down the control key.
 198 Now, slowly, press the "B" key, while still holding the control key, eight or
 199 nine times.  You will see the cursor move backwards, that is, to the left,
 200 one position for each time you press the "B" key.  Soon you will reach the
 201 beginning of the line, at which time, you cannot go any further back, because
 202 that is the beginning of your text.  Emacs will cause your terminal to beep
 203 at you, to indicate that you have made an error. Wait for all the beeping to
 204 finish, and release the control key.
 205 
 206      We now want to move forward to the place after the word "is", in order
 207 to insert the word "some".  Hold down the control key, and type the letter
 208 "F" several times.  "Control F" is the Emacs command for "forward", i.e.,
 209 move the cursor forward one character.  While still holding down the control
 210 key, type F's until the cursor is under (or covering, on some terminals), the
 211 letter "s" of the word "sample".  If you type the Control F too many times,
 212 simply type Control B's until you get to the right place.  What you  are
 213 doing now is the most important form of interaction with Emacs- issue commands
 214 until you are "at the right place", or "the right thing has happened", doing
 215 one command at a time and observing its effect, and repeating that process
 216 until you have achieved what you want.  This is _^Hi_^Hn_^Ht_^He_^Hr_^Ha_^Hc_^Ht_^Hi_^Hv_^He editing, as
 217 opposed to counting the number of lines or characters, etc., and issuing
 218 commands to move  15 lines and 4 characters, etc. (although you can do this
 219 too in Emacs if you really need to).  Visual feedback is the most important
 220 single feature of Emacs.
 221 
 222      Now we are at the "s" of sample, and we wish to put the word "some"
 223 right there (i.e., at the cursor).  That is trivial: simply type the four
 224 letters s, o, m, and e.  You will watch Emacs move the rest of the line over
 225 and you now have on that line:
 226 
 227     This is somesample text.
 228 
 229 with the cursor still under the "s" of "sample".  Immediately, we perceive a
 230 problem: there is no space  between "some" and "sample".  We did not enter a
 231 space, this is exactly what we told Emacs to do.  Let us enter a space:
 232 simply hit the space bar. Now we have:
 233 
 234      This is some sample text.
 235 
 236 with the cursor still under the "s" of "sample".  We have now fixed the
 237 text we wished to.  Note that in order to type in the new word, "some", we did
 238 not have to say anything special, we just moved the cursor to the right
 239 place, and started typing.  Whenever we type a non-control character (other
 240 than #, @, and \), it goes into the text at the cursor, and moves the cursor
 241 over one to the right.  If you think for a little while, you will notice that
 242 that is what it did when we were simply typing in the lines on the screen!
 243 
 244      Now we must get back to the end of the document, where we had left off
 245 when we decided to add the word "some" to the first line.  We can do this by
 246 going to the N^H_ext line, and the N^H_ext line, until we are where we want to be.
 247 As you doubtless surmise, we do this with the "Control N" command, N^H_ for
 248 N^H_ext.  Hold down the control key (as you have seen, if you do _^Hn_^Ho_^Ht, the
 249 characters you type will go into your text!), and press "N" twice.  Each time,
 250 the cursor will move one line down.  We are now on the right line.  You will
 251 find that you are at the end of that line;  Emacs tries to keep you in the same
 252 "column" when going between lines, but the line with "Multics" on it is much
 253 shorter than the line you started from (the first line, which now says,
 254 "This is some sample text."), so you are as far as you can be on this line.
 255 
 256      Now let us finish the sentence "Multics is a computer system."  We see
 257 that the cursor is right after the "s" in Multics": if we just type "is", we
 258 will get
 259 
 260      Multicsis
 261 
 262 which is surely not what we want.  So type  a space, and the cursor moves to
 263 the right as a space goes into your text.  Now continue entering the words
 264 
 265      is a computer system.
 266 
 267 and sure enough, your entire text appears correct before you:
 268 
 269      This is some sample text.
 270      Here is more text yet.
 271      Multics is a computer system.
 272 
 273      You may want to continue experimenting with the things you have just
 274 learned:  when you are done, you will have to leave the editor: this is done
 275 as follows: type a "Control X" followed by a "Control C" (C^H_ for C^H_ommand
 276 level).  This is not an easy command to type or remember, but that is
 277 reasonable, because you may be editing for hours, and you will only type it
 278 once.  One way to type it is to hold down the control key, and type an "X" and
 279 a "C" while holding it.  Emacs will respond,
 280 
 281      Modified buffers exist.  Quit?
 282 
 283 because you have done work that you have not written out (we will learn
 284 about writing out work later).  Answer "yes" (type the letters y, e, and s,
 285 and a carriage return).  Emacs will clear the screen, and leave you at
 286 Multics Command level.
 287 
 288      We have now learned the six most important Emacs commands:
 289 
 290      #              Erase the last character
 291      Control F      Go F^H_orward one character.
 292      Control B      Go B^H_ackward one character.
 293      Control N      Go to the N^H_ext line.
 294      Control P      Go to the P^H_revious line.
 295      Control X Control C
 296                     Quit the editor.
 297 
 298 
 299      Practice using them until you are thoroughly familiar with them.  They
 300 are the most important and useful commands.  With these commands, and one or
 301 two others, you can do just about anything you will ever be called upon to
 302 do.  All the other commands just make it easier to do more complex things,
 303 but you can always move around and type in text with these commands.
 304 
 305 
 306                            Deleting and Killing.
 307 
 308      Next we will learn how to delete text.  We already know something about
 309 this subject; we know how to use "#" to delete characters that we type in
 310 as we type them in.  Here we will learn to remove other portions of the text.
 311 Enter Emacs as before. Type in the following text, as we did before.  So that
 312 you can follow the lesson properly, be careful to break the lines
 313 (type carriage return) exactly as you see here:
 314 
 315      Once upon a time there were four bears.  They lived in a house on the
 316      edge of the forest.  There was a father bear, a mother bear, and a
 317      baby bear. One day the bears went out in the woods.
 318 
 319 The last thing you should have typed should have been "woods.", and the
 320 cursor is to the right of the period in "woods.".  Let us now fix the
 321 obvious designated excess of bears: we want to change the word "four" to
 322 "three" in the first line.  As all else in Emacs, the way we do this is to
 323 "go" to the place in question, with the cursor, and then perform local
 324 surgery on the text at the cursor.  Let us use what we have learned before,
 325 and use the "previous line" command (invoked by striking "Control P")
 326 twice, to get up to the first line.  We now find we are in the middle of
 327 the word "They", and we wish to go backward on this line until we are at the
 328 word "four".  So we use the "backward characters" command, invoked by
 329 striking "Control B", for "backwards".  We probably have to strike it about a
 330 dozen times, so we should hold down the "control key" (like a shift key) with
 331 one finger and hit "B" about a dozen or so times until the cursor is right
 332 at the letter "f" of the word "four".  If we go too far, go "forward by
 333 characters" with "Control F" until we are at the "f" of "four".
 334 
 335      This may have seemed long and difficult to get to that word; there are
 336 easier ways, and we will learn them in time, but for now, we will continue to
 337 present the fundamental concepts and commands in the order which will allow
 338 you to do the most as soon as possible.
 339 
 340      We now wish to change the word at the cursor to the word "three".  In
 341 Emacs, we do not "change" or substitute.  We get rid of what we don't want,
 342 and type in what we do want. So what we will do is _^Hd_^He_^Hl_^He_^Ht_^He the word
 343 "four", and type in the word "three" (which we already know how to do!).
 344 The way we will delete the word "four", for now, is by destroying it one
 345 character at a time. We will use the "delete character" command, which
 346 is invoked by hitting "control D", "D" for D^H_elete.  Do this once, by
 347 holding down "control" and pressing "D" _^Ho_^Hn_^Hc_^He while "control" is down.
 348 Watch the screen. You will see that the first line is now changed:
 349 
 350      Once upon a time there were our bears.  They lived in a house on the
 351 
 352 The "f" has disappeared! It has been _^Hr_^He_^Hm_^Ho_^Hv_^He_^Hd from the line; the cursor
 353 is now under the "o". Note that if we type a (D^H_O^H_N^H_'T^H_ do it) "t" now,
 354 it will say
 355 
 356      Once upon a time there were tour bears.  They lived in a house on the
 357 
 358 So let us get rid of the rest of the word "four" by hitting "Control D"
 359 three more times, slowly, watching the screen.  We now have, when this is
 360 done:
 361 
 362      Once upon a time there were  bears.  They lived in a house on the
 363 
 364 The cursor is under the _^Hs_^He_^Hc_^Ho_^Hn_^Hd of the two spaces now between the words
 365 "were" and "bears".  The rest is easy; we type the letters t, h, r, e, and e,
 366 and the word "three" appears letter by letter, between "were" and "bears",
 367 pushing over the rest of the line as we type it. So we have now learned the
 368 "delete character" command, which is used by typing "Control D", which
 369 physically removes the character at the cursor from the screen and our text.
 370 
 371      Often we need to delete a lot more than a few characters; we want to
 372 remove large pieces of lines, or many lines. We will now learn the
 373 "kill lines" command, which is invoked by striking "Control K", K^H_ for K^H_ill
 374 Lines.  We wish to change the last sentence,
 375 
 376      One day the bears went out in the woods.
 377 
 378 to
 379 
 380      The bears often ate porridge.
 381 
 382 Again, the way we do this is to position the cursor to the point we want to
 383 change, and then operate upon the text.  We want to get to the letter "O" in
 384 the word "One" on the last line.  Use the Backward Character, Forward
 385 Character, Next Line, and Previous Line commands (Control B, Control F,
 386 Control N, Control P) any way you know how until the cursor is under the
 387 "O" of the word "One".  Now type a Control K, and watch the screen.  All the
 388 text between the cursor and the end of the line wil vanish from the screen
 389 and from the text.  Although we could just type in the new sentence right here
 390 and now, there is a very important feature to be learned at this point.
 391 Type a Control Y. This invokes the "Yank" command: watch the screen.  The text
 392 we had just killed is brought back.  The "Yank" command brings back anything
 393 we just killed, if we decide that killing it was a mistake.  In this way,
 394 we can fix damage that we do by accident by mistaken or inadvertent killing of
 395 text.  Almost every command in Emacs that deletes text puts the text it deletes
 396 into a special safe place called the _^Hk_^Hi_^Hl_^Hl _^Hr_^Hi_^Hn_^Hg, where the Yank command
 397 can find it.  What is more, killed text _^Hs_^Ht_^Ha_^Hy_^Hs in the kill ring
 398 so that you can yank it back many commands later, or even somewhere else in
 399 your text after you accidentally or purposefully killed it; this way, you need
 400 not notice your mistake as soon as you make it.
 401 
 402      The "Delete Character" command does not put the characters it kills
 403 in the kill ring; if you accidentally delete a character, it is easy enough
 404 to retype it; if you delete many characters by hand, it is probably not a
 405 mistake.
 406 
 407      The Yank command has left the cursor after the sentence it has
 408 retrieved; let us re-position the cursor, with the cursor-moving commands we
 409 know, back to the "O" in "One", and use "Control K" again to remove the
 410 sentence.  Now type in the new sentence,
 411 
 412      The bears often ate porridge.
 413 
 414 and the correction is made.
 415 
 416      "Kill Lines" (Control K) is a very versatile command, that does different
 417 things depending upon whether it is used in the end of a line or not.
 418 Let us enter some new text.  Type "Control N" (Next Line) about four times
 419 to get to a fresh place on the screen.  Note that the cursor is at the
 420 left margin; these lines are empty.  Type the following well-known verse:
 421 
 422      I wandered lonely as a cloud
 423      That floats on high over vales and hills.
 424      And all at once, I saw a crowd
 425      A host of lovely daffodils.
 426      Beside the lake, beneath the trees,
 427      Fluttering and dancing in the breeze.
 428 
 429 Position the cursor to under the "I" which starts the verse, using
 430 all the cursor positioning commands that you know about.  Now delete
 431 all the text on that line, that is "Kill to the end of the line", by typing
 432 a Control K.  Observe the screen: the line becomes blank. Now type
 433 Control K again, and watch the screen.  All the rest of the poem moves up.
 434 We now state what Control K does, and this explains why:
 435 
 436           When not at the end of a line (i.e., at the beginning, or in the
 437              middle, Control K deletes all text between the cursor and the
 438              end of the line, leaving the cursor at what is now the end of the
 439              line.
 440 
 441           When at the end of a line, Control K "removes the carriage-return",
 442              or "sticks the next line on to the end of this one", making one
 443              line.  If the line that the cursor is on has nothing in it
 444              (except the carriage return), this means make this line go away.
 445 
 446 Now type Control K again. The line
 447 
 448      That floats on high over vales and hills
 449 
 450 will empty out.  Type it once more, and that (now empty) line will disappear,
 451 and the cursor will be at the beginning of the next line of the poem.  You can
 452 now see that typing Control K many times will delete lines one by one, off the
 453 screen, as you type it.
 454 
 455      Now we will show some magic.  Invoke the "Yank" command again, by
 456 striking a Control Y, and watch the screen.  Both lines we deleted came back,
 457 intact!  There has been something going on behind the scenes on the kill ring
 458 as we have been typing Control K's:  If we type an unbroken succession of
 459 Control K's, the "killed text" is _^Hm_^He_^Hr_^Hg_^He_^Hd on the kill ring, so that one yank
 460 gets it all back.  Because of this feature, we do not have to painstakingly
 461 reconstruct text that we killed line-by-line as we have done.  If we did not
 462 want to bring all of it back, it is no problem to go back and kill some of the
 463 text that we yanked back and didn't want, but this is a lot easier than having
 464 to retype text that we killed and couldn't yank back.  Almost all Emacs
 465 commands that delete text participate in this _^Hk_^Hi_^Hl_^Hl _^Hm_^He_^Hr_^Hg_^Hi_^Hn_^Hg with themselves and
 466 each other to help you recover accidentally deleted text easily, no matter how
 467 you deleted it.
 468 
 469 
 470      We have now learned three new commands, for deleting text:
 471 
 472      Control D      Delete Character at cursor.
 473      Control K      Kill to end of line, if not already at end of line.
 474                     If at end of line, merge line with next line.
 475      Control Y      Yank back text that we accidentally killed.
 476 
 477      All these commands, of course, delete what is at the cursor, or bring
 478 back text at the position of the cursor.
 479 
 480      Type some text, and experiment with these commands until you feel
 481 comfortable using them, and then exit the editor as we did earlier.
 482 
 483                           Reading and writing files.
 484 
 485      One of the most important things to know how to do is to read in Multics
 486 Files, and write them out.  There are three commands for doing this, and we
 487 will now learn about them.  When we read in a file, it is read into a
 488 _^Hb_^Hu_^Hf_^Hf_^He_^Hr.  Each file will be read into its own buffer.  When we read a file in,
 489 the first twenty or so lines will appear on the screen, just as though
 490 you had typed them in.  You only see as many lines at one time as fit on
 491 the screen, however, the whole file is there, and if you try to position
 492 the cursor to some line that is not on the screen, either by doing
 493 Control N's so that the cursor tries to go off the bottom, or Control P's
 494 so that the cursor tries to go off the top, or any other way,  Emacs will
 495 choose such lines to display on the screen such that the line you want the
 496 cursor to be on is indeed shown.
 497 
 498       Let us read in a file.  For this we use the "Find File" command.  Enter
 499 Emacs in the usual fashion.  Because we do not read in files that often while
 500 editing, the Find File command requires two keystrokes.  It is invoked by the
 501 two-key sequence "Control X Control F" (the F is for F^H_ind F^H_ile).  Type this
 502 by holding down the control key, and typing an X and an F while it is down.
 503 
 504      You will see the cursor go to the bottom of the screen, below the
 505 mode line, and Emacs will say
 506 
 507           Find File:
 508 
 509 with the cursor at the end of the word "File: ".  This is called a _^Hp_^Hr_^Ho_^Hm_^Hp_^Ht:
 510 Emacs is waiting for you to type an "answer" to its question, in this case,
 511 the pathname of the file to be read in.  You are now in the _^Hm_^Hi_^Hn_^Hi_^Hb_^Hu_^Hf_^Hf_^He_^Hr, a
 512 little one-line window below the mode line, used for answering prompts.
 513 We were prompted in the minibuffer previously when we tried to exit Emacs with
 514 modified buffers.  Type the pathname of a file: a good pathname is
 515 
 516      >doc>subsystem>emacs>emacs.info
 517 
 518 which is the command writeup for Emacs.  Type this pathname: you need not put
 519 any spaces before or after it.  If you make a mistake while typing, you can use
 520 #, Control B, Control D, Control F, or any other command to edit the
 521 pathname itself while you are typing it!  End the pathname with a
 522 carriage-return.  Assuming you have typed the pathname correctly,
 523 Emacs will now print the word "Reading.." in the minibuffer, letting you know
 524 that it is reading in this file, and strike it out when it has finished
 525 reading it.  A little later, you will see the screen start to fill up with the
 526 first windowful of the file.  The cursor will be at the first character of the
 527 first line.  Now look at the mode line.  You will see that the buffer
 528 name is no longer "main", but "editor". The buffer name is taken from
 529 the first component of the entry name of the file read in (in this case,
 530 the file was "editor.info", so it is "editor").  Below the mode line is
 531 something new, the full pathname of the file in this buffer.  This is called
 532 the _^Hp_^Ha_^Ht_^Hh _^Hl_^Hi_^Hn_^He, and tells us exactly what file we are editing.  Of course, we
 533 are not really editing that file, but a copy of it, and the changes we may
 534 make will not be reflected to that file unless we try to write out the
 535 buffer to the file.
 536 
 537      Now type a Control X, and an Equal Sign (=).  Be sure to release the
 538 control key before striking the equals sign.  Be careful to remember to hold
 539 the shift key if equal-sign requires a shift on your terminal.  Emacs will
 540 print in the minibuffer,
 541 
 542      513 lines, current = 1
 543 
 544 or something similar. Control X = is the Line Counter command.  It tells you
 545 how many lines there are in your document, and what line number the cursor
 546 is currently on.  Control X = is a handy command to know.
 547 
 548      Now type Next Line commands (Control N) slowly until the cursor is
 549 on the line right above the minibuffer.  Be very careful, just this time,
 550 to do this slowly enough, so that the cursor stays in the main window.
 551 Now note carefully the contents of the line it is on.  I cannot tell you
 552 what line that is, because I don't know how many lines your terminal has
 553 on its screen, and that governs what line your cursor will be on now.
 554 Now strike control N once more.  You will see Emacs rewrite many lines
 555 on your screen, and, if your terminal has the capability to do so, move
 556 many lines around.  When it is finished, the cursor will be at the
 557 beginning of a line in the middle of the screen.  Look at the line
 558 above that.  You will note that it is the same line that was at the bottom
 559 of the screen a second ago.  Control N indeed went to the next line of the
 560 text after the line the cursor was on, as it is supposed to.  Now do another
 561 Control X =.  Emacs will say something like
 562 
 563           513 lines, current = 22
 564 
 565 If you look at the screen, you will see that the cursor is on the twelfth
 566 or so line of the screen, not the 22nd!  However, you are editing the
 567 file (or the buffer) and not the screen!  The line you are on is indeed the
 568 twenty-second line of the file.  If you were near the end, you might be on
 569 the 500th line or so, even though there are only 21 lines or so in the main
 570 window.  Since you can only display about 21 lines at once, Emacs chooses
 571 _^Hw_^Hh_^Hi_^Hc_^Hh 21 lines automatically to make sure the line that you want the
 572 cursor to be on is on the screen.
 573 
 574      You can now edit this file as though you had typed it in, using all the
 575 commands that you know.  You can move the cursor about, delete characters,
 576 kill lines, or enter new text at will.  Try putting in a new word or
 577 killing a line.  At once, the word
 578 
 579      Modified
 580 
 581 will appear in the minibuffer, letting you know that you have changed the
 582 file since you read or wrote it, and will have to write it
 583 out if you want your work to be saved.  It is not easy to do five hundred
 584 Control N's to get through the file; we will learn more ways later of
 585 moving around buffers faster.
 586 
 587      Having made some editing changes to the file, we want to write it out.
 588 The command that writes back a file that you read it is called "Save same
 589 file": it is invoked by the two-character sequence Control X Control S
 590 (S for S^H_ave).  Try it.  You will get the error message
 591 
 592           Incorrect access on entry.
 593 
 594 You cannot write out this file, because it is my file, and I did not give you
 595 the access required to write on my file.  So let us write it out to a copy in
 596 our own directory:  For this, we use the Write File command, which is invoked
 597 by the two-character sequence Control X Control W (W for W^H_rite File).  Enter
 598 this sequence.  Emacs will prompt in the minibuffer:
 599 
 600      Write File:
 601 
 602 Now type the pathname of a place you want to write it to:
 603 
 604      myinfo.info
 605 
 606 End with a carriage return.  You will see the path line change to indicate
 607 the new pathname.  As Emacs is writing it, you will see the word "Writing.."
 608 appear in the minibuffer.  When the word "Written." replaces the word
 609 "Writing..", you know that the file has been successfully written out to
 610 the Multics Storage System.
 611 
 612      Now you can edit some more, and move around within the buffer, and
 613 when you wish to write the file out again, to the same place it was last
 614 written to, Save Same File (Control X Control S) will do the trick. Again,
 615 the Writing../Written in the minibuffer lets you know when Emacs is done
 616 writing.
 617 
 618      We have now learned four new commands:
 619 
 620      Control X Control F      Find file, read in a file. Asks for pathname
 621                                  in the minibuffer.
 622 
 623      Control X Control S      Save Same File, writing out the buffer to the
 624                                  last place it was read from or written to.
 625 
 626      Control X Control W      Write File: Write a file to a new place.
 627                                  Asks for pathname in the minibuffer.
 628 
 629      Control X =              Line Counter: tell how many lines in the buffer,
 630                                  and what line we are on.
 631 
 632 
 633                                   Searching
 634 
 635 
 636      A fundamental ability that is needed in editing is that of looking
 637 for a particular sequence of characters, or _^Hs_^He_^Ha_^Hr_^Hc_^Hh_^Hi_^Hn_^Hg.  In the context of
 638 E^H__^Hm_^Ha_^Hc_^Hs, this means finding a given sequence of characters in the buffer,
 639 and moving the cursor to that point.  There are two simple commands
 640 for searching in Emacs: we will learn them next.
 641 
 642      Enter Emacs as usual.  Enter the following text:
 643 
 644      Now is the time and the only time for those who have
 645      their time to give their time.
 646 
 647      Using Control P (Previous Line) and Control B (Backward Character)
 648 move the cursor to the upper left hand corner (under the "N" of "Now")
 649 of the screen.  We will now search for the word "time".  We use the
 650 String Search command, which is gotten by typing a Control S. Do it.
 651 Emacs responds in the minibuffer:
 652 
 653      String Search:
 654 
 655 We now enter the four letters t, i, m, and e.  End the string with a carriage
 656 return.   You will see the cursor return
 657 to the main window, but now it will be immediately after the first occurence
 658 of the word "time".  Let us replace the word "time" here by "day".  We will
 659 learn a little trick.  By all rights, we should go backwards (Control B)
 660 four times, and then delete characters (Control D) four times to delete
 661 the word "time".  That would work; however, there is an easier way.  Type
 662 a pound sign (#).  Note that the "e" of "time" goes away.  If we type
 663 the "#" another three times, the t, i, and m will go away too!  This is what
 664 pound sign always does: it deletes the character to the left of the cursor,
 665 whether you just typed it in or not.  Think about it.  When you type in a
 666 character, the cursor moves to the right of it, and it is now to the left of
 667 the cursor.  Typing pound sign makes it go away because pound sign deletes
 668 the character to the left of the cursor.  This is distinct from Control D,
 669 which deletes the character _^Ha_^Ht the cursor.
 670 
 671      Finish deleting the first occurence of the word "time", and type in
 672 "day".  Now let us look for "grime".  Type a Control S, and in response to the
 673 prompt "String Search:  ", type the letters g, r, i, m, and e, and a
 674 carriage return.  Emacs will respond
 675 
 676      Search fails.
 677 
 678 in the minibuffer, because it could not find the string "grime", and
 679 the cursor remains in the place where it was when the Control S was
 680 typed.  Now let us again look for "time".  Type a Control S, the letters
 681 t, i, m, and e, and carriage-return.  The cursor advances to the next "time"
 682 in the buffer.  Do it again, and the same thing happens.  Note carefully
 683 that Control S only searches forward in the buffer, from where the cursor
 684 is at the time it is used to the end of the buffer. It will not look
 685 backwards.  That is why it puts you _^Ha_^Hf_^Ht_^He_^Hr the string it finds, so that
 686 it will not find the same one all the time.  Note how easily we can find
 687 the same string many times in a line.
 688 
 689      Now go back to the beginning of the buffer, with Control P's and
 690 Control B's.  We are going to look for the string "time" again, but this
 691 time, a little bit differently.  Type a Control S.  Emacs again prompts,
 692 
 693      String Search:
 694 
 695 Type a carriage return..  You will see Emacs put the word "time" right in the
 696 minibuffer, as though you had typed it, and find the first "time".  When you
 697 answer a search command's prompt with an "empty search string", that is to
 698 say, typing carriage return, Emacs will re-use the last "search string"
 699 (sequence of characters) you were searching for.  This applies to all the
 700 various search commands.  Using this, we can search many times for the same
 701 thing, without having to retype it into the minibuffer.  Search two or three
 702 times for "time" again (please do this, so that this lesson will continue to
 703 work).
 704 
 705      Now we will learn a very important Emacs command, "Get out of what you
 706 are doing", which is gotten by issuing a Control G.  Try it.  Your terminal
 707 will beep at you.  Control G always causes your terminal to beep at you.
 708 Now type a Control S again.  Emacs will prompt in the minibuffer, as always,
 709 
 710      String Search:
 711 
 712 Suppose we decide that we didn't want to search for anything, and that typing
 713 the Control S was a mistake.  Now type a Control G: the cursor will exit
 714 the minibuffer, and the terminal will beep.  The search command has been
 715 aborted.  Control G  can always be used to exit the minibuffer to abort
 716 any command that you change your mind about in midstream, such as
 717 Find File, or Write File, etc.  It can also be used after typing a
 718 large number of cursor movement commands to cause your terminal to "beep"
 719 when they are all done.  Sometimes, this is useful when the system is slow,
 720 as a way of letting you know that Emacs has "caught up" to what you told it
 721 to do.  Control G is very important, it is an "out" whenever you start
 722 doing something that you change your mind about, or aren't sure what you
 723 typed.  If you ever find yourself in the minibuffer with a prompt that
 724 you think you didn't  ask for, or don't understand, like
 725 
 726      Eval:
 727 
 728 you can be sure that typing a Control G will get you out of it without
 729 doing any harm.
 730 
 731      The next command we will learn about is Reverse String Search:  it is
 732 invoked by striking a Control R.  Try it.  Strike a Control R.  Emacs will
 733 prompt in the minibuffer:
 734 
 735      Reverse String Search:
 736 
 737 Type carriage return, like for Control S (String Search).  The string "time"
 738 will appear in the minibuffer, as we had promised.  The cursor will be left
 739 _^Hb_^He_^Hf_^Ho_^Hr_^He (i.e., under the first character of) the first occurence
 740 of "time" going backwards from where the cursor was when you typed the
 741 Control R.  If the cursor was right after a "time", it will now be at the
 742 front of the same one.  Do it again.  The cursor will go one "time" back
 743 each time, until there are no more between the cursor and the beginning of the
 744 buffer, at which time Emacs will respond
 745 
 746      Search Fails.
 747 
 748 in the minibuffer.  If we want to change one of these "time"s to an
 749 "hour", we need only type four Control D's (Delete Character) and the
 750 word "hour" after finding one.
 751 
 752      Reverse String Search is just like String Search, except
 753 
 754           1. It goes backward to the beginning of the buffer, while forward
 755              search goes forwrd to the end.
 756           2. It leaves the cursor _^Hb_^He_^Hf_^Ho_^Hr_^He (at the front of) the found
 757              string, while String Search leaves it _^Ha_^Hf_^Ht_^He_^Hr.
 758 
 759 Otherwise, String Search and Reverse String Search both prompt in the
 760 minibuffer, take a string terminated by a carriage return to use for a search
 761 target, and use an empty string (a carriage return as answer) to indicate that
 762 the last search string used should be used again.
 763 
 764      When you are searching for something in Emacs, you have to know if you
 765 want to search forward or backward for it, from where you are now; usually,
 766 you know this.  If you don't, you should search forward.  If the search fails,
 767 just hit a Control R and a carriage return, and Emacs will search backward for
 768 the same string.  If _^Ht_^Hh_^Ha_^Ht search fails, the string is really not in the
 769 buffer.
 770 
 771      We now have learned three new commands:
 772 
 773      Control S      String Search. Prompts for a string in the minibuffer,
 774                        which must end with a carriage return.  An empty string
 775                        uses the last string over again.  Searches forward for
 776                        that string to the end of the buffer, and leaves you
 777                        after it.
 778 
 779      Control R      Reverse String Search.  Same as above, but goes backward.
 780                        Leaves you at start of found string.
 781 
 782      Control G      (Command Quit) Get out of anything, and beep the
 783                        terminal.  Often used to get out of minibuffer
 784                        prompts that you change your mind about.
 785 
 786 
 787                            Two Very Useful Commands
 788 
 789      We will now learn two useful commands that you will use all the time.
 790 We will not give any examples here, because what they do is so simple.  Try
 791 them yourself any way you want, but learn them.
 792 
 793      Control A      Go to beginning of line.  Moves the cursor to the beginning
 794                        of whatever line it is on.  The way to rememeber it
 795                        is that "A is the first letter at the beginning of the
 796                        alphabet".  We could not use "B" for "Beginning",
 797                        because, as we know, Control B is for "Backward
 798                        Character".
 799 
 800      Control E      Go to end of line (E for E^H_nd).  Moves the cursor
 801                        to the end (after the last character, before the
 802                        carriage return) of whatever line it is now on.
 803                        On a line with nothing on it (nothing _^Hi_^Hn it but a
 804                        carriage return), this does nothing.
 805 
 806 
 807 
 808                        Wiping, the Mark, and the Region
 809 
 810      We will now learn three new concepts, and three new commands.
 811 We will learn them in order to be able to delete arbitrary extents of text
 812 (i.e., "from here to there", or "all that stuff") as opposed to killing
 813 lines and characters carefully to get rid of exactly what we want.  Enter
 814 Emacs.  Type in a paragraph or so of text, of your choice.  Choose a
 815 few words next to each other somewhere.  It is all right if they are not
 816 on the same lines.  Let us delete this "extent", that "much" of the text.
 817 The command we will be using is Wipe Region, which is invoked from
 818 Control W (for W^H_ipe Region).  We tell it what to "wipe", that is, wipe off
 819 the screen and out of the text, or delete, by giving it the "here" and
 820 "there", that is, the "limits" or "boundaries" of the region to delete.
 821 It will delete all the text between the two points we tell it to.
 822 
 823      How do we specify the "region" of our buffer that control W is to delete?
 824 By its limits.  How do we specify the limits?  One limit will be the cursor
 825 at the time we strike the Control W.  The other is specified by an "invisible
 826 cursor" called "the mark".  There is at most one "mark" in each buffer.  Until
 827 we "set the mark", there is no mark in the buffer.  Type a Control W.
 828 You will find that Emacs will complain that there is no mark, and nothing
 829 will happen.  We "set the mark" by moving the cursor to the place we
 830 want "the mark" to be, and issuing the command "Set the Mark", which is
 831 invoked by Control @. This is a very tricky command to type.  It is typed,
 832 like any control character, by holding the control key, and typing, in
 833 this case, the character @.  On some terminals, you may even have to
 834 hold Control and Shift at once to make this happen, if you normally have
 835 to hold the Shift key to get an @.  If you have trouble with this, ask someone
 836 familiar with the terminals in use at your site; tell him you are trying to
 837 "Generate an ASCII NULL, or a Control At Sign", and hopefully he or she can
 838 show you how to type one.
 839 
 840      Move the cursor to be under the _^Hf_^Hi_^Hr_^Hs_^Ht character of the first word that
 841 you have singled out for deletion.  We will set "the mark" here.  Type the
 842 Control @.  Absolutely nothing will happen: this command doesn't "do"
 843 anything visible.  Now move the cursor to right _^Ha_^Hf_^Ht_^He_^Hr the _^Hl_^Ha_^Hs_^Ht letter of the
 844 _^Hl_^Ha_^Hs_^Ht word in the group we singled out for deletion.  We are now ready, in
 845 principle, to issue the Control W (Wipe Region) command, but let's not.
 846 There is usually something we want to do right before issuing a Control W: We
 847 want to check that "the mark" is where we think it is, because it might have
 848 been some time ago that we set it.  For this we use the command "Exchange
 849 Point and Mark" ("point" is the name for the place in the buffer that the
 850 cursor is located at.  If you don't understand the difference between that
 851 and the cursor itself, ignore it for now.) This command switches the cursor
 852 and "the mark" around, putting the cursor where the mark was and the mark
 853 where the cursor was.  The visible effect of this is to move the cursor to
 854 where the mark was, so we can see where it was.  The "Exchange Point and Mark"
 855 command is issued by typing Control X Control X (i.e., two Control X's in a
 856 row).  Remember "X" for E_^Hxchange.  Do it.  The cursor will move to under the
 857 first character of the region we are trying to delete, the place where we
 858 had set the mark.  Now before doing any other commands, do another
 859 Exchange Point and Mark (Control X Control X) to get back.
 860 It is very important that you do not move the cursor at all before typing
 861 the second pair of Control X's, or you will exchange the mark with the
 862 wrong point!  It is very common to type Control X Control X, Control X
 863 Control X in this way, to "verify" the "region" between the "point" and
 864 "the mark".
 865 
 866      Now issue the Control W (Wipe Region) command.  You will see that all
 867 the text you singled out for deletion disappears from the screen (and thus
 868 from your text).  If there was a carriage return in the middle of them, you
 869 will see that that too has gone, and one big line now replaces the two lines
 870 between which the carriage return had been.
 871 
 872      Like The Kill Lines command (Control K), the Wipe Region command
 873 (Control W) puts what it removes in the kill ring.  Type a Control Y now
 874 (the Y^H_ank command).  All the text you had deleted reappears.  If you
 875 ever hit Control W by accident (for instance, instead of Control E), and
 876 see loads of text mysteriously vanish, just type Control Y and it will
 877 all come back.  As a matter of fact, if you ever see text vanish off your
 878 screen or out of your buffer for a reason that you don't think you understand,
 879 the chances are better than even that simply typing a Control Y will
 880 fix it all up.
 881 
 882      A useful feature of the Yank command is that it puts "the mark" at the
 883 _^Hb_^He_^Hg_^Hi_^Hn_^Hn_^Hi_^Hn_^Hg of the text it retrieves, and (as can be seen), leaves
 884 the cursor after it.  This has two implications that should be noted:
 885 
 886      1. After you have yanked some text, no matter for what reason, you
 887         can make it go away again simply by typing Control W (Wipe Region),
 888         since the cursor and the mark exactly specify the boundaries of
 889         what was yanked.
 890 
 891     2.  After you have yanked something, no matter for what reason, you
 892         can get to (move the cursor) to the beginning of the yanked text
 893         by exchanging the cursor and the mark, simply by typing
 894         two Control X's, the "Exchange Pont and Mark" command.
 895 
 896      If we had known the second of these facts when we were learning about
 897 Control K (Kill Lines), we could have gotten to the beginning of the
 898 sentence
 899 
 900      One day they went out in the woods.
 901 
 902 after we had yanked it back simply by typing Control X Control X.
 903 
 904      The text in the buffer between the cursor and the mark is called
 905 "the region".  There are many Emacs commands besides Wipe Region (Control W)
 906 which use the region, and the commands we learned for setting the limits
 907 of the region and testing what they are are useful for all of them.
 908 
 909      We have learned three new commands:
 910 
 911      Control @      Set the mark to be where the cursor is now.
 912 
 913      Control X Control X
 914                     Switch the cursor and the mark around, to show us
 915                     where the mark was.  The mark is now where the cursor
 916                     was, and the cursor is now where the mark was.
 917 
 918      Control W      Wipe Region.  Remove the text between the mark and the
 919                     cursor from the text and the screen.  Save it on the
 920                     kill ring for possible subsequent yanking.
 921 
 922                               Numeric Arguments
 923 
 924 
 925      Next we learn about how to say "go FIVE characters forward", or
 926 "go FOUR next lines down" and so forth.  Commands for which it is meaningful
 927 and useful to specify "how many times" to do them usually will accept what
 928 is called a "numeric argument", which is essentially a repetition count.
 929 For instance, if we give the "Next Line" command (Control N) a numeric
 930 argument of 25, it will go 25 lines down instead of one line down as it usually
 931 does.  If we give the "Delete Character" command (Control D) a numeric
 932 argument of 6, it will delete 6 characters, instead of the one it usually
 933 does.
 934 
 935      Search around on your keyboard for a key labelled "ESC", "ESCAPE",
 936 "ALT", or "ALTMODE", or something like that.  This is called the "ESCAPE"
 937 key, which generates a character called the "ESCAPE character".   We
 938 will refer to it by the letters ESC; this means strike and release the
 939 ESCAPE key, do _^Hn_^Ho_^Ht type the letters E, S, and C!
 940 
 941      We specify a numeric argument to a command by typing an ESC character
 942 (hitting and releasing the ESCAPE key once), the number we want, and
 943 the command we want to receive the argument.  For instance, to delete
 944 six characters, we would type the _^Ht_^Hh_^Hr_^He_^He keys
 945 
 946              ESC  6   Control-D
 947 
 948 That is, strike the escape key, the 6 key, and a Control D in that order.
 949 All the characters will disappear at once: you will not see them go one by
 950 one.  Similarly, if you said
 951 
 952           ESC 249 Control-N
 953 
 954 while on the first line of a large file, the screen would fill immediately
 955 with lines 240 to 261 (roughly) of the file, with line 250 and the cursor
 956 in the middle.  You will be spared watching the cursor and the screen
 957 step through 250 lines one by one; it is done all at once.
 958 
 959      The following commands that we have already learned about accept
 960 a numeric argument to mean "Do it that many times".  The complete list
 961 is given in the Emacs reference document:
 962 
 963           Control B           Backward Character
 964           Control D           Delete Character
 965           Control F           Forward Character
 966           Control N           Next Line
 967           Control P           Previous Line
 968 
 969 If you give a numeric argument to Control K (Kill lines), it does _^Hn_^Ho_^Ht
 970 do that many Control K's, it does something more useful.  Starting
 971 with the current point on the current line, it kills entirely (removes)
 972 that many _^He_^Hn_^Ht_^Hi_^Hr_^He lines.  Thus, if you are at the beginning of a line
 973 (doing a Control A, Go to Beginning of Line can ensure this),
 974 
 975           ESC 4 Control-K
 976 
 977 will delete this and the next three lines entirely.  Of course, these
 978 lines will be put as one on the kill ring, and will "_^Hk_^Hi_^Hl_^Hl _^Hm_^He_^Hr_^Hg_^He"
 979 with preceding or following "kill type" commands as described above.
 980 
 981      The "Yank" command also does something useful and different with
 982 a numeric argument.  The kill ring is so called because it is like a ring
 983 of text excerpts that were deleted.  Whenever you kill some text,
 984 the "ring" is rotated one of its ten positions, and the newly killed text
 985 goes in the front position, replacing what had been in the tenth position.
 986 It is like a merry-go-round with ten horses, and one on/off point.
 987 The ten positions on the kill ring thus contain the last ten text excerpts
 988 that you killed.  (When kill merging occurs, this does not happen, as the
 989 new text gets "stuck on to" the text in the ring at the on/off point).
 990 When you use a "Yank" command (Control Y), it is always the latest thing
 991 that you killed (i.e., the excerpt at the on/off point) that is retrieved.
 992 If you want the _^Hs_^He_^Hc_^Ho_^Hn_^Hd latest thing instead, simply give the
 993 Yank command a numeric argument of 2 by typing
 994 
 995           ESC 2 Control-Y
 996 
 997 instead of just
 998 
 999           Control-Y
1000 
1001 and that will happen.
1002 
1003           There is a wonderful command that expresses the following situation.
1004 "I deleted some text.  Then I went somewhere else, and I deleted some
1005 more text.  Then I decided that the first text I deleted was really O.K.;
1006 deleting it was a mistake.  So I went back to the point where I deleted it
1007 from, and used the Yank command (Control Y).  However, that was a mistake,
1008 because it brought back the text from the second thing I had deleted,
1009 which was, indeed, the last thing I had deleted.  I wish I could say
1010 "Get rid of that stuff, and bring back the previous saved text in the
1011 kill ring." "
1012 
1013      There is such a command.  It does precisely that.  It gets rid of
1014 the text between the cursor and the mark (which was, presumably just yanked
1015 by mistake), without saving it on the kill ring, "rotates" the kill ring
1016 one position _^Hb_^Ha_^Hc_^Hk_^Hw_^Ha_^Hr_^Hd_^Hs, and retrieves the text at the on/off station.
1017 
1018 It is typed by the two-character sequence
1019 
1020           ESC y
1021 
1022 That is to say, press the two keys, ESCAPE and Y (lower case or capital, it
1023 does not matter) one after the other.  (Be careful to type the two-key
1024 sequence deliberately and firmly; do NOT hold down the ESC key while typing
1025 Y: it is NOT like the CONTROL key.)   It is called the "Wipe this and Yank
1026 Previous" command:
1027 
1028      ESC Y          Wipe this and Yank Previous.  I don't like what
1029                        I just yanked.  Get rid of it, and bring out the
1030                        previous thing I killed.
1031 
1032 By doing many ESC Y's in a row, until you "find the kill that you want",
1033 you can "go shopping" in the kill ring for saved text.
1034 
1035      Whether you realize it or not, normal letters and numbers are actually
1036 Emacs commands, too!  For instance, we know that Control D means "Delete the
1037 character at the cursor".  But what does an ordinary "D" mean?  What happens
1038 when you type an ordinary "D"?  What happens when you type any number or letter
1039 or punctuation mark?  It goes into the buffer, and appears on the screen.
1040 The first thing we ever did was to type ordinary text into Emacs.
1041 Printing characters (other than #, @, and \), are said to be
1042 _^Hs_^He_^Hl_^Hf-_^Hi_^Hn_^Hs_^He_^Hr_^Ht_^Hi_^Hn_^Hg, because if you type one, it inserts itself into
1043 the text.
1044 
1045      We mention this now because giving a numeric argument to a self-inserting
1046 character causes it to insert itself that many times.  For instance,
1047 if we type
1048 
1049           ESC 2 4 Q
1050 
1051 we will see twenty four Q's appear on the screen all at once.  This is a
1052 good way to get lines of dashes, underscores, stars, etc.
1053 
1054      If ever you type a numeric argument, or are in the middle of typing
1055 a numeric argument, or have just typed  ESC, and you decide that you
1056 didn't mean it, or you are not sure as to whether you typed the numeric
1057 argument or not, type a Control G, which G^H_ets you out of anything.  The
1058 reassuring beep of Control G will verify that any possible numeric argument
1059 has been discarded.
1060 
1061                   The First Help Command, and Local Displays
1062 
1063      There is a command that will tell you what command a given key performs.
1064 This is a good command to use if you are not sure what a given key does, and
1065 you do not have the documentation on hand.  It displays the documentation for
1066 a given command on the screen.  It is called Describe Key, and is invoked by
1067 striking the two-key sequence
1068 
1069      ESC ?
1070 
1071 Try it.  Let's find out about what Control E is and does.
1072 Type an ESC, and then a question mark.  Emacs will prompt in the
1073 minibuffer with
1074 
1075      Explain Key:
1076 
1077 Now actually type a Control E, in the usual manner.  Emacs will probably wait
1078 a little while before responding, especially if this is the first time you
1079 have used ESC ? since entering Emacs and system load is heavy.  Be patient.
1080 The documentation for Control E, Go to End of Line, will appear at the top of
1081 the screen, replacing whatever text you were editing on the screen.  Bu do not
1082 worry, it did not destroy your text; it is just being "displayed" to you on
1083 the screen "in front of" your text.  The line of dashes and stars:
1084 
1085      -- * * * * * * * * * * * * --
1086 
1087 is there to let you know that your buffer has not been destroyed, but simply
1088 that there is information being displayed for you to see "in front of" it.
1089 Such a display is called a L^H__^Ho_^Hc_^Ha_^Hl D^H__^Hi_^Hs_^Hp_^Hl_^Ha_^Hy.  We will shortly learn how to get
1090 rid of the local display, when we are finished viewing it, and restore the
1091 window on our buffer to the screen.
1092 
1093      The documentation for Control E begins with the line
1094 
1095      ^E        go-to-end-of-line
1096 
1097 "^E" is the shorthand for "Control E" which is used in the reference document,
1098 and in displays and error messages produced by Emacs.  It is a good shorthand,
1099 because "Control X Control Q ESC B Control D" etc., can get long-winded.
1100 We will use this convention from hereon in.  When we say "^A", we will mean
1101 "Control A", i.e., hold down the control key and strike an A", _^Hn_^Ho_^Ht the
1102 character "^" followed by an "A".
1103 
1104      "go-to-end-of-line" is the _^Hc_^Ho_^Hm_^Hm_^Ha_^Hn_^Hd _^Hn_^Ha_^Hm_^He associated with
1105 ^E. At this stage, it serves only to remind us of what ^E does.  When a great
1106 deal of proficiency in using Emacs has been acquired, these command names
1107 can be used in computer programs to build commands of your own.
1108 As a matter of fact, once you know the command name, you can "connect" any key
1109 of your choice to any command of your choice if you don't like the default
1110 layout of what key does what (see the writeup of the "set-key" and
1111 "set-permanent-key" extended commands if you want to learn about this).
1112 
1113      The documentation describing go-to-end-of-line follows the line giving
1114 the key name and command name.  The documentation is the same that you would
1115 find in the Emacs reference document; it describes everything there is to know
1116 about the command in question.
1117 
1118      When we have finished viewing the local display of the command
1119 documentation, we wish to remove it from the screen.  If you just start
1120 editing again, typing editor commands, the display will vanish as soon as you
1121 start typing, putting back on the screen what had been there.  However, you
1122 might not know where the cursor was "supposed to be", because the local
1123 display is standing there in front of it.  For this reason, a command is
1124 provided that does _^Hn_^Ho_^Ht_^Hh_^Hi_^Hn_^Hg _^Ha_^Ht _^Ha_^Hl_^Hl.  Since typing _^Ha_^Hn_^Hy editor command makes the
1125 local display go away, this command may be used for making local displays go
1126 away without doing anything else.  It is invoked by striking the Linefeed key
1127 on your terminal.  The "noop" (No Operation) command is invoked by Linefeed
1128 (which is the same as Control J on all terminals).  For reasons too complex to
1129 describe here, it is recommended, and cannot hurt, to hit Linefeed two or
1130 three times to get rid of a local display.
1131 
1132      Sometimes, local displays will take more than one screen.  In this case,
1133 the last line of the screen will say
1134 
1135      --More?-- (Space = yes, CR = no)
1136 
1137 If you see this on the last line of the window, hit the space bar once to see
1138 each successive screen of the local display.  When you are at the last screen
1139 of the local display, the line of dashes and stars
1140 
1141      -- * * * * * * * * * * * --
1142 
1143 will appear, and Linefeeds may be used to restore the buffer to the screen.
1144 If, during a multi-screen local display, you decide that you do not want to
1145 see the rest of the display, typing a carriage return instead of the space bar
1146 will terminate the display and restore the buffer to the screen.
1147 
1148      Occasionally, you may forget what command a given key invokes, or need to
1149 find out "what you just did by accident".  You can ask for the name of the
1150 command invoked by a given key without the documentation.  This can be
1151 preferable at low terminal speeds, or on a slow system, where the local
1152 display can take some time, or if you just need a reminder of what is
1153 "connected" to some given key. This can be done with the Describe Key command
1154 by giving it a numeric argument, i.e.,
1155 
1156      ESC 1 ESC ?
1157 
1158 (a four-key sequence).  Type that.  Emacs will prompt:
1159 
1160      Show Key Function:
1161 
1162 Type, for instance, a Control W.  Emacs will respond in the minibuffer,
1163 
1164      ^W = wipe-region
1165 
1166 which is precisely what we wanted to know.
1167 
1168    We now know two new commands:
1169 
1170      ESC ?          Describe Key.  Prompts for you to type a key,
1171                        and supplies the documentation for that key as
1172                        a local display.  If given a numeric argument,
1173                        tells what command is invoked by that key.
1174 
1175      Linefeed       No Operation.  Type it two or three times to remove
1176                        a local display from the screen.
1177 
1178 
1179                           T^H__^Hh_^He B^H__^Hu_^Hf_^Hf_^He_^Hr _^Ha_^Hn_^Hd _^Ht_^Hh_^He S^H__^Hc_^Hr_^He_^He_^Hn
1180 
1181 
1182      Very often we wish to "page" through a document, reading through it like
1183 a book, either to actually read it, or to "flip through" until we arrive at
1184 the place we want to see or edit.  Using Emacs, this is accomplished by
1185 "paging" through the text in the buffer screen by screen.  That is to say,
1186 after we finish reading or looking at the text on the screen, we want to see
1187 the next screenful (actually, the next windowful).  The next windowful of text
1188 is that text in the buffer which immediately follows the text now in the
1189 window.  That is the text we wish to progress to, and fill the window with.
1190 The command for doing this is "Next Screen", which is gotten by striking
1191 Control V (for V^H_iew Next Screen).  This is a very easy key to type with your
1192 left hand alone; use your thumb, while holding down the control key, to page
1193 through successive windowfuls of a document.
1194 
1195      Read in some file and "^V through it".  You will note that each time you
1196 strike a Control V, the cursor will be left at the upper left-hand corner of
1197 the screen: not only has the window been filled with new text, but the cursor
1198 is now in a different place in the buffer, at the beginning of the text which
1199 fills the window.  The text now in the window, of course, is not the only part
1200 of the buffer you may edit.  If, for instance, after using ^V, you use a ^P to
1201 go to the previous line, you will observe Emacs choosing a different portion
1202 of the buffer to display in the window.  Emacs usually chooses its window,
1203 (i.e., what part of the buffer to show in the window) automatically, governed
1204 by where in the _^Hb_^Hu_^Hf_^Hf_^He_^Hr you moved the cursor. ^V is one of several ways, and
1205 the first we have learned thus far, to explictly select what will be displayed
1206 in the window.
1207 
1208      Note that when you use ^V, the first line of the new screen will be the
1209 same as the last line of the old screen.  This is to give you some context,
1210 and a sense of continuity, so you will know you haven't missed anything, or
1211 forgotten what you were reading while the screen was being refilled.
1212 
1213      As we can page "forward" through a buffer, so we can page "backward" as
1214 well.  As this is less common, it takes two keystrokes.  The two-key sequence
1215 ESC V invokes the "Previous Screen" command.  Remember, C^H__^Ho_^Hn_^Ht_^Hr_^Ho_^Hl V for the next
1216 screen, E^H__^Hs_^Hc_^Ha_^Hp_^He V for the previous one.  ESC V will make the last line of the
1217 new screen be the same as the first line of the old one.
1218 
1219      Now we can go forward and backward through the buffer line by line (^N
1220 and ^P), character by character (^F and ^B), windowful by windowful (^V and
1221 ESC V), or by searching (^S and ^R), and we will learn many more ways yet.
1222 However, among the most common of needs are to go to the _^Hb_^He_^Hg_^Hi_^Hn_^Hn_^Hi_^Hn_^Hg of the
1223 buffer, the _^He_^Hn_^Hd of the buffer, and to a given line number.
1224 The command "Go to Beginning of Buffer" is invoked by the two-key sequence
1225 ESC <. Think of the "less than sign" as an arrow pointing backward to the
1226 beginning of the buffer.  Using ESC < will place the first windowful of the
1227 buffer on the screen, and place the cursor at the very first character of the
1228 buffer.  This is often useful when  going through the entire buffer looking
1229 for something or changing things one by one as you see them.
1230 
1231      As you might have guessed, ESC > is "Go to End of Buffer".  The "greater
1232 than sign" may be thought of as a little arrow pointing to the end of the
1233 buffer.   It places the last  windowful of the buffer on the screen, and
1234 places the cursor on the newline character (the "carriage return") which ends
1235 the last line of the text in the buffer.  That is the furthest place in the
1236 buffer that the cursor can go; it is the end of the last line in the buffer.
1237 There is no way to move the cursor to beyond that character.  If, after using
1238 ESC >, you see the cursor on a line by itself, that simply means that there is
1239 an "empty line", i.e., one with nothing but a newline in it, at the end of the
1240 buffer.
1241 
1242      When editing Multics programs, it is often very useful to go to a given
1243 line number (e.g., the 240'th line of the buffer), because many Multics tools
1244 give diagnostics in terms of line numbers in their input files.  If you happen
1245 to be positioned on the first line of the buffer, going to the 241's line is
1246 easy; just do 240 ^N's by typing
1247 
1248      ESC 2 4 0 ^N
1249 
1250 If you are not on the first line, you could use ^X= (Line Counter) to figure
1251 out where you are, subtract, and use ^P or ^N with the right numeric
1252 argument, but this is hardly reasonable.  Therefore, Emacs provides the
1253 "Go to Line Number" command, which is invoked by the two-key sequence
1254 ESC G (G for G^H_o).  The numeric argument to ESC G tells it what line number to
1255 go to.  For instance,
1256 
1257      ESC 2 5 9 ESC G
1258 
1259 will move the cursor to (the beginning of) line 259 of your text, no matter
1260 what line you are on now.  As is the case with searching, ^N and ^P, and any
1261 Emacs cursor movement commands, if the target of the motion (the place in the
1262 _^Ht_^He_^Hx_^Ht being gone to) is not on the screen, a new window will be selected and
1263 displayed automatically such that the target of the motion _^Hi_^Hs on the screen.
1264 
1265      When editing multiple files, each use of ^X^F (Find File) will result in
1266 a new buffer.  You may switch between buffers with the "Go Buffer" command,
1267 which is invoked by ^XB (B for B^H_uffer).  Be careful when typing this command:
1268 be sure to release the control key before typing the "B" (the B need not be
1269 capitalized;  Emacs does not distinguish between upper and lower case letters
1270 in editor commands (other than self-inserting characters)).  When you type a
1271 Control X and a B, Emacs will prompt for a buffer name to go to.  Type the
1272 name of the target buffer, ended by a carriage return.  If you give the name
1273 of a buffer that does not exist, Emacs will create such a buffer, and display
1274 it on the screen (you will see an empty window).  If you give the name of a
1275 buffer that does exist, Emacs will refresh the screen with the last windowful
1276 of that buffer that you were editing, that is to say, such a window of that
1277 buffer that the last point you were at with the cursor when editing in it is
1278 now on the screen, and the cursor will be placed at that point.
1279 
1280      Note that when you switch buffers with "Go Buffer", the mode line
1281 changes, to indicate the new buffer name (and the new buffer modes, if they
1282 have changed as well, because modes may be different in different buffers, and
1283 are "remembered" in that buffer.  We will learn later about some useful
1284 modes.)  The path line (the line under the mode line) will change as well, to
1285 let you know the pathname of the file which was read into this buffer (or last
1286 written out from it).
1287 
1288      You may list all of the buffers in a given invocation of Emacs with the
1289 "List Buffers" command, ^X^B (Control X, Control B).  The listing of buffers
1290 will be displayed as a local display; hit linefeed two or three times to get
1291 rid of it, as all local displays.  The name of each buffer, and the pathname
1292 of the file in it, if any, will be displayed.  To the left of the buffer names
1293 will be two symbols, for some buffers, ">" and "*". The "greater than" sign
1294 will be placed to the left of the name of the buffer in which you are now
1295 editing.  The star will be next to the name of any buffer which is "modified",
1296 i.e., has never been written out (but isn't empty), or has been modified since
1297 last read in or written out.  Only when there are "no stars" will ^X^C allow
1298 you to exit Emacs without querying you.
1299 
1300      Go Buffer (^XB) provides a convenient service for going back to the last
1301 buffer you came from.  If you answer its prompt
1302 
1303      Buffer:
1304 
1305 with _^Hj_^Hu_^Hs_^Ht a carriage return, i.e., no buffer name, Go Buffer will go back to
1306 the last buffer you had been in before entering the current buffer.  This may
1307 be used to "visit" another buffer and come back easily.
1308 
1309      Occasionally, you may not believe what you see on the screen.  Sometimes
1310 bad telephone lines, or unexpected messages from Multics, or things you just
1311 don't understand ("I _^Hk_^Hn_^Ho_^Hw that's not there!) may cause the screen contents to
1312 become invalid.  This may be due to hardware problems, bugs in new versions of
1313 Emacs, or bugs in your terminal.  At any rate, there is a need to clear the
1314 entire screen and put it back the way it should be, without any regard for
1315 what was there.  This is like clearing one's throat, or clearing the top
1316 of the table.  This is accomplished with the Redisplay Command, which is
1317 gotten by striking ^L.  ^L is used for this purpose because many terminals,
1318 and some parts of the Multics Communications System, associate the Control L
1319 character with the clearing of screens. Try striking ^L; you will see the
1320 screen clear, and be refilled, with the cursor in the middle of the screen
1321 (unless you are at the top of your text buffer, in which case it will be at
1322 the top).  On fast terminals, ^L can be used just to "reposition the window"
1323 such that the line with the cursor on it is at the middle of the window.
1324 (this will work on all terminals, but may be too slow to be useful on slow
1325 lines).  ^L will also make local displays go away, and on fast terminals, is
1326 often used for this purpose as well.  ^L with a numeric argument is used to
1327 reposition the window, i.e., keep the cursor at the same point in the buffer,
1328 but  "move the window around" so that the line with the cursor on it
1329 is at a place of your choosing in the window; a numeric arguemtn of zero is
1330 the top of the window, and so forth. See fundamental-mode.info for more
1331 information on this.
1332 
1333      We have now learned seven new commands for manipulating screens and
1334 buffers:
1335 
1336      Control V      Next Screen. View the next screen of the buffer
1337                        in the window, and leave the cursor at its top.
1338 
1339      ESC V          Previous screen.  View the previous screen of the
1340                        buffer in the window, leave the cursor at its top.
1341 
1342      ESC <          Go to the beginning of the buffer.
1343 
1344      ESC >          Go to the end of the buffer.
1345 
1346      Control X B    Go Buffer.  Prompt for the name of another buffer,
1347                        and switch to it, displaying it on the screen at the
1348                        last point you left off editing it. If you give
1349                        ^XB no buffer name, it will go to the previous buffer
1350                        you had been in.
1351 
1352      Control X Control B
1353                     List Buffers.  Show as local display the names,
1354                     file pathnames, and modified/not modified status of
1355                     all existent buffers.
1356 
1357      Control L      Redisplay Command.  Clear the screen and refresh it,
1358                     eliminating possible non-understood garbage.  With a
1359                     numeric argument, reposition the window.
1360 
1361      ESC G          Go to Line Number.  Go to the beginning of the line
1362                     whose line number is supplied as a numeric argument.
1363 
1364 
1365                         A^H__^Hp_^Hr_^Ho_^Hp_^Ho_^Hs _^Ha_^Hn_^Hd E^H__^Hx_^Ht_^He_^Hn_^Hd_^He_^Hd C^H__^Ho_^Hm_^Hm_^Ha_^Hn_^Hd_^Hs
1366 
1367      Some commands are issued by a single keystroke, such as ^D, which invokes
1368 the Delete Character comand, delete-char.  Other, less common ones, are
1369 invoked by two-key sequences beginning with ESC, such as ESC G, which invokes
1370 the command go-to-line-number.  Others, less common yet, are invoked by
1371 two-character sequences beginning with ^X (X for E_^Hxtended key).  Commands that
1372 are the least common have to be invoked by actually typing in the name of the
1373 command.
1374 
1375      By "less common", we do not mean that a command is obscure, little-used,
1376 less important, or not widely known or understood.  What we do mean is that
1377 during the course of normal editing, you will use it fewer times than more
1378 common commands.  For instance, you only use ^X^C (quit-the-editor) once per
1379 editing session, but it is one of the first and most important commands you
1380 must learn!  The commands that you must type most often are made the easiest
1381 to type.  The simplest commands to type (the single key "control"'s) are those
1382 that you would want to type _^Hr_^Ha_^Hp_^Hi_^Hd_^Hl_^Hy.  A fine example of this is ^T,
1383 twiddle-chars, which exchanges the last two characters typed.  It is not a
1384 necessary command, as two pound signs and two more characters can do whatever
1385 it does.  But given that ^T can be typed in one character, it is useful.
1386 
1387      The commands known as "Extended Commands" are those invoked by typing
1388 their command names at Emacs.  An example of an extended command is "fillon",
1389 which enters "fill mode" in a buffer.  Fill mode is a setup of a buffer such
1390 that you do not have to worry about the ends of lines when typing text, and
1391 never type carraige return (except, of course, when ending prompts, or where
1392 you want explicit control over the format and line-breaks of your document).
1393 Fill mode is ideal for typing in text from a written page, or composing a
1394 document spontaneously.  One types and types and lines get broken
1395 automatically.
1396 
1397     To invoke the "fillon" command, we clearly cannot just type the characters
1398 "fillon" at Emacs, or they will go into the buffer like any other characters.
1399 We must somehow tell Emacs that we wish to type the name of an extended
1400 command.  The "Extended Command" command, which is invoked by ESC X, does this.
1401 The "X" is for E_^Hxtended.  Type the two-key sequence Escape X.
1402 Emacs will prompt in the minibuffer,
1403 
1404      Command:
1405 
1406 Now type the word "fillon" (no quotes, just the six characters), followed by a
1407 carriage return.  You will see the name of the "fill" _^Hm_^Hi_^Hn_^Ho_^Hr _^Hm_^Ho_^Hd_^He appear in the
1408 mode line after the name of the current _^Hm_^Ha_^Hj_^Ho_^Hr _^Hm_^Ho_^Hd_^He (Fundamental).
1409 
1410      In general, we invoke an extended command by typing ESC X, the name of
1411 the command (and then any arguments, if the extended command takes command
1412 arguments), and a carriage return.
1413 
1414      Now try fill mode.  Type in a long, very long sentence, consisting of
1415 very many real, separate words.  Watch what happens when you get to the end of
1416 the screen, as you type successive words.   Do not worry about typing carriage
1417 return; your lines will be automatically "filled" as they become too long.
1418 
1419      The most important extended command is the "apropos" extended command.
1420 "Apropos is a word (from the French) meaning "about, or having to do with".
1421 It is used to find the names, and keys, of all commands that have to do with a
1422 given topic.  It is used if you remember something about a particular command,
1423 but you cannot remember the key that invokes this particular command, or what
1424 its name is.  The "apropos" extended command will find all commands that have
1425 a given character string in their name, and tell you what keys invoke them.
1426 
1427      For instance, suppose you forgot the name of the key that went to the end
1428 of a line.  Type
1429 
1430      ESC X apropos end CR
1431 
1432 (The "CR" means "carriage return").  Apropos will display, as a local display,
1433 the names of all commands available in this buffer whose names contain the
1434 character string "end".  It will tell you of ^E (go-to-end-of-line),
1435 ESC > (go-to-end-of-buffer), and a few surprises (such as ^XM, s_^He_^Hn_^Hd-mail), and
1436 others.  Once we learn from apropos what commands are available, we may be
1437 jolted into recognition ("Oh, yes, ^E was go-to-end-of-line!"), or need more
1438 information ("Hmm, ^E looks right. I'd like to know more about it."), and use
1439 ESC ? (Describe Key), by typing, say ESC ? ^E, to get the full documentation
1440 on a particular command.
1441 
1442      Apropos will also list all relevant extended commands, when listing
1443 commands whose names speak of a particular topic.  We cannot use ESC ?
1444 (Describe Key) to find out about extended commands, for it prompts for a
1445 single key, and tells about it.  If we typed "fillon" to ESC ?, it would read
1446 the "f", and tell us about "f" ("f" puts an f into the buffer, etc.), and put
1447 "illon" into our buffer.  So, there exists an extended command to retrieve
1448 documentation for extended commands: it is called "describe".  To find out
1449 about the "fillon" extended command, we type
1450 
1451      ESC X describe fillon CR
1452 
1453 The command documentation will be shown as a local display.  We can find out
1454 about describe itself,
1455 
1456      ESC x describe describe CR
1457 
1458 or about apropos
1459 
1460      ESC X describe apropos CR
1461 
1462 if that is what we want to do.
1463 
1464 
1465     We now know the three commands that constitute the core of the Emacs
1466 self-documentation and help system:
1467 
1468      ESC ?          Describe Key.  Prompts for a one or two key sequence,
1469                         and gives as local display the documentation for the
1470                         command invoked by that key.
1471 
1472      ESC X describe <command-name> CR
1473                     Gives as local display the documentation for the extended
1474                        command whose name is given.
1475 
1476      ESC X apropos <topic> CR
1477                    Gives as local display a list of commands whose names
1478                       contain the character string given as <topic>, and
1479                       tells what keys invoke them, in the current buffer.
1480                       Relevant extended commands are also listed.
1481 
1482      The "<" and ">"'s in the above descriptions do not mean that you should
1483 type <'s and >'s.  They are being used as "pointy brackets".  That is to say,
1484 "<topic>" means any character string, being some topic you want help on.
1485 We use the "pointy brackets" so that you will not be misled into typing the
1486 character string "topic".
1487 
1488      We have also learned of the "fillon" extended command:
1489 
1490      ESC X fillon CR
1491                     Enters "fill" minor mode in the current buffer.  This
1492                        causes overlength lines to be wrapped around and broken
1493                        as they cross the "fill column". Ask the "describe"
1494                        extended command to tell you more about fill mode.
1495 
1496 
1497                                 W^H__^Ho_^Hr_^Hd C^H__^Ho_^Hm_^Hm_^Ha_^Hn_^Hd_^Hs
1498 
1499      Some of the most useful commands in Emacs are those which relate to
1500 words.  Even if we are typing computer programs or other non-English text
1501 material, the facility to move around word by word, delete words, etc., is a
1502 very useful one.
1503 
1504      The word movement and deletion commands have a deliberate parallelism
1505 with the character movement and deletion commands:  ^F, ^B are Forward
1506 Character, Backward Character, and ESC F, ESC B are Forward Word, Backward
1507 Word.  Similarly, ^D and # are Delete Character and Rubout Character, while
1508 ESC D and ESC # are Delete Word and Rubout Word.
1509 
1510      A "word" in Emacs consists of an unbroken string of upper and lower case
1511 alphabetics (a-z and A-Z), underscores and backspaces.  For instance,
1512 "new_payroll" is a word, "_^Hb_^He_^Hg_^Hi_^Hn" is a word, "delete-char" is two words, and
1513 "segname$entry" is two words.  "March, I said." is three words.
1514 
1515      The "Forward Word" command (ESC F) moves the cursor forward over one
1516 word.  If the cursor is currently on a character that is part of some word,
1517 the cursor will be moved to the first character after that word.   For
1518 instance, if the cursor is on the "e" of the word "Yes" in the fragment
1519 
1520      "Yes, it is true," he said.
1521 
1522 and the Forward Word (ESC F) command is issued, the cursor will be left
1523 positioned on the comma after the word "Yes".  If the cursor is now on a
1524 character between two words (even if they are separated by many blank lines,
1525 or many lines full of punctuation, breaker bars, etc.), Forward Word will
1526 position the cursor to the first character after the _^Hn_^He_^Hx_^Ht word in the buffer.
1527 Thus, if the cursor is on the comma after the word "Yes" in the above example,
1528 and the Forward Word command is issued, the cursor will be moved to the space
1529 after the word "it".
1530 
1531      Moving around by words is often the fastest way, or the most convenient
1532 way to move the cursor to where you want to go from where you are.  It is
1533 quite common to type ESC F ESC F ESC F etc. to move a word at a time, watching
1534 the cursor.  You might also judge "I want to go six words forward, roughly",
1535 and issue the key sequence
1536 
1537      ESC 6 ESC F
1538 
1539 which is allowed, because Forward Word accepts a numeric argument as
1540 a repetition count.  However, doing ESC F's one at a time to move forward
1541 word-by-word is still an often-needed technique.  There are some problems in
1542 that technique, however, because any slip-up in typing
1543 
1544      ESC F ESC F ESC F ESC F
1545 
1546 and you may have
1547 
1548      ESC F ESC F ESC ESC F F ESC F
1549 
1550 or similar, which is not what you want.  (If, by the way, you fall into this
1551 trap, and ESC ESC gives you "Eval:", do a ^G to get out of it.)  Therefore,
1552 the command Re-execute Command (^C) is provided to make this and similar
1553 operations easier and less error-prone.   Typing a Control C re-executes the
1554 last editor keystroke command entered.  Thus, after typing ESC F to go forward
1555 a word, each typing of the single keystroke ^C will go forward another word.
1556 With good system response, this can be very effective.
1557 
1558      To go backward by words, Backward Word (ESC B) is provided.  It is
1559 similar to Forward Word, and most other Emacs forward/backward motion
1560 commands.  If the cursor is on some character of a word, other than the first
1561 character, it will be moved to the first character of the word.  If on the
1562 first character of a word, or between words, Backward Word will move to the
1563 first character of the previous word (i.e., further back in the buffer).
1564 If we have the fragment
1565 
1566      He said, "Come, let us reason together."
1567 
1568 and the cursor is on the "e" of "let", Backward Word would move it to the "l"
1569 of "let".  Successive Backward Word's would move it to the "C" of "Come",
1570 the "s" of "said", and the "H" of "He".  ^C (Re-execute Command) may be used to
1571 repeat Backward Word (or any other Emacs command) in the same way as we
1572 described for Forward Word.
1573 
1574      Here is a good example of the interaction between Forward Word and
1575 Backward Word.  To put parentheses around the sobriquet "Tony" in
1576 
1577      Anthony Tony Burns.
1578 
1579 assuming that the cursor is at the "." after "Burns", we type
1580 
1581      ESC B ESC B
1582 
1583 to put the cursor at the "T" of "Tony. Then we type an open-parenthesis, which
1584 inserts itself at the cursor, leaving us with
1585 
1586     Anthony (Tony Burns.
1587 
1588 and the cursor still on the "T" of "Tony", which has now moved over.
1589 Now ESC F puts the cursor on the space after "Tony", and typing the close
1590 parenthesis finally gives us
1591 
1592      Anthony (Tony) Burns.
1593 
1594 with the cursor on the space after "(Tony)".  The total keystroke sequence
1595 was
1596 
1597      ESC B ESC B ( ESC F )
1598 
1599 How easy.
1600 
1601      Deleting words is perhaps the second most common editing operation (after
1602 deleting characters) when entering text.   Most often, we type a word, and
1603 decide that we did not want that word, or mistyped it sufficiently thoroughly
1604 that we wish to retype it entirely.  We wish to delete the last word we typed,
1605 which is to say (note the similarity to the use of #), the  word to the left of
1606 the cursor.  Parallel to #, ESC #, Rubout Word, is used for this purpose.  It
1607 deletes the word, or what is left of a word, if the cursor is in the middle of
1608 a word, to the left of the cursor.  Its action can best be described as though
1609 it were doing
1610 
1611           ^@        Set the Mark
1612           ESC B     Backward Word
1613           ^W        Wipe Region
1614 
1615 That is to say, Rubout Word does a Backward Word, and removes all text between
1616 where the cursor winds up and where it started.  Successive Rubout Word's
1617 remove words farther and farther back.   Like all deleting commands (other
1618 than character deleting), Rubout Word participates in kill-merging, which is
1619 to say, that after one or any number of successive words have been removed by
1620 Rubout Word, a yank (^Y) will get them all back.  If successive words, and the
1621 punctuation and whitespace between them, are deleted by Rubout Word, a single
1622 Yank command will get back the whole deleted area, intact, punctuation,
1623 whitespace, and all, as it initially stood.  Rubout Word accepts a
1624 numeric argument as a repetition count, and, like all commands, can be
1625 repeated with ^C.
1626 
1627      Note that when issued in the middle of a word, Rubout Word will delete
1628 that part of the word to the left of the cursor.  If immediately after a word,
1629 it will delete only the characters of the word.  At any other point, it will
1630 delete all characters between the cursor and the previous word, and that word.
1631 All these facts follow from the definition given above.
1632 
1633      Forward word deletion may be performed by Delete Word, invoked by ESC D.
1634 It deletes the word, or part of a word, to the right of (including the
1635 character at) the cursor.  It deletes forward, from the point where the cursor
1636 is, to the point where Forward Word, ESC F, would go.   Successive ESC D's
1637 will participate in kill-merging, and delete text word-by-word, all capable of
1638 being retrieved in one Yank (^Y).  If issued with the cursor on the first
1639 character of a word, Delete Word will remove the entire word.  If issued in
1640 the middle of a word, Delete Word will remove all the characters from the one
1641 at the cursor up to and including the end of the word.  If issued between
1642 words, it deletes all whitespace and punctuation up until the next word, and
1643 the next word along with it.  Consider the sentence
1644 
1645      We have not any melons today, Mrs. Johnson.
1646 
1647 with the cursor under the "r" of "Mrs.". To replace "melons" by "pears",
1648 we type
1649 
1650      ESC B ESC B ESC B
1651 
1652 
1653 to put us on the "m" of "melons", and the ESC D, to delete the m, e, l, o, n,
1654 and s, leaving us with
1655 
1656      We have not any  today, Mrs. Johnson.
1657 
1658 with the cursor on the second of two spaces between "any" and "today".  We
1659 then type the word "pears".
1660 
1661      A unique set of capabilities is provided by three commands which control
1662 the "case" of words, i.e., lower case ("jack"), upper case ("JACK"), or
1663 "Capitalized Initial", ("Jack").   These three commands are:
1664 
1665      ESC L          Lower Case Word
1666      ESC U          Upper Case Word
1667      ESC C          Capitalize Initial Word
1668 
1669      Each of these commands may be issued with the cursor _^Ho_^Hn a word, that is,
1670 on any character of it, or _^Hi_^Hm_^Hm_^He_^Hd_^Hi_^Ha_^Ht_^He_^Hl_^Hy _^Ha_^Hf_^Ht_^He_^Hr a word to alter the case of that
1671 word.  For instance, suppose we had just typed
1672 
1673      thomas
1674 
1675 with the cursor immediately after the "s" of "thomas".  To capitalize
1676 "thomas", we need only issue the two-key sequence ESC C, and we have
1677 
1678      Thomas
1679 
1680 The cursor is always left immediately after the word whose case was
1681 transformed.  If we wish to capitalize several words, say
1682 
1683      thomas alva edison
1684 
1685 we can move the cursor to any letter of the word "thomas", type ESC C, leaving
1686 us on the space after "Thomas", ^F to put us on "alva", ESC C, leaving us
1687 between "Alva" and "edison", and ^F and ESC C one last time, leaving us after
1688 "Edison".
1689 
1690      The three word-case-altering commands all leave the cursor immediately
1691 after the word whose case is altered.  Since the character immediately after a
1692 word is a good place from which to issue a word-case-altering command,
1693 we can position the cursor immediately after the word "thomas", and
1694 type  ESC C ESC L ESC U ESC C ESC L etc., and watch Thomas, thomas, THOMAS,
1695 Thomas, thomas, etc., replace each other on the screen until we find the one
1696 we like.  A word-case-altering command may be issued from anywhere within  a
1697 word or immediately after it, but it will leave the cursor immediately after
1698 the word.
1699 
1700      The word-case-altering commands deal with all the characters in a word,
1701 not just the first.  Thus, a word like "MaGicAl" can be converted to
1702 "Magical", "magical", or "MAGICAL" by use of these commands.  Thus, the
1703 word-case-altering commands can be used to fix typos caused by holding down a
1704 shift key too long.  For instance, in trying to type "Joralemon", we might
1705 type "JOralemon".  An easy job for ESC C, Capitalize Initial Word.  Issuing
1706 this command after we type the "n" gives us at once "Joralemon".
1707 
1708      If a word-case-altering command is issued between two words, but _^Hn_^Ho_^Ht
1709 _^Hi_^Hm_^Hm_^He_^Hd_^Hi_^Ha_^Ht_^He_^Hl_^Hy after the first word, it will alter the case of, and move to the
1710 end of, the next word.  Thus, sequences of ESC C ^F ESC C ^F, etc., will
1711 capitalize successive words, regardless of how much punctuation or whitespace
1712 separates them.
1713 
1714      Related to the word-case-altering commands are the underlining and
1715 underline-removing commands, ESC _ and ESC -. These commands are used to
1716 cause a word to be underlined, or to remove the underlining from an underlined
1717 word.  It is important to note that most current video terminals either do not
1718 have the ability to underline text at all, or can only do it in ways that are
1719 either very limited or not useful.  Therefore, underlined text in Emacs
1720 appears as
1721 
1722      H\010__\010e_\010l_\010l_\010o
1723 
1724 where
1725 
1726      H^H__^He_^Hl_^Hl_^Ho
1727 
1728 is wanted. The "\010"'s are backspaces; they are shown in this way because
1729 almost no video terminals can overprint characters, even among those that have
1730 limited underlining capability.  The text in the buffer, which will be written
1731 out to your file, actually contains the proper number and placement of
1732 backspaces: the "\010" representation is only the way they _^Ha_^Hp_^Hp_^He_^Ha_^Hr on the
1733 screen.
1734 
1735      Typing in backspaces in order to underline words when talking to Multics
1736 is confusing, difficult, and error-prone enough when using a printing
1737 terminal:  the familiar sequence of "H e l l o backspace backspace backspace
1738 backspace backspace _ _ _ _ _" or worse is even less convenient on a video
1739 terminal that cannot overstrike.
1740 
1741      A word can be automatically underlined correctly by use of the Emacs
1742 Underline Word command, ESC _ (the two-key sequence, Escape Underscore.  Be
1743 careful to remember to use the shift key to get the underscore if, on your
1744 terminal, you would use the shift key any other time to get an underscore!) To
1745 use this command, position the cursor to any place within a word to be
1746 underlined, or immediately after, just as for the word-case-altering commands.
1747 ESC _ will then cause this word to be underlined correctly, and leave the
1748 cursor positioned immediately after it.  Just as with the word-case-altering
1749 commands, to type in a word and underline it, say "_^Hb_^He_^Hg_^Hi_^Hn", we type the seven
1750 keys
1751 
1752      b e g i n ESC _
1753 
1754 The fact that we issued the Underline Word command immediately to the right of
1755 a word (which we had just entered) causes that word to be underlined.
1756 
1757      The command ESC - (Escape Minus-sign), Remove Underlining From Word,
1758 is used to take out underscores and backspaces (i.e., de-underline) a word
1759 that is underlined.  Like the word-case-altering commands and Underline Word,
1760 it may be issued with the cursor at any point within  the word of interest, or
1761 immediately after it.  Just as with the  word-case-altering commands,
1762 successive ESC _'s and ESC -'s will add and remove underlining from the same
1763 word, in alternation.
1764 
1765       As with the word-case commands, to underline successive words,
1766 
1767      ESC _ ^F ESC _ ^F ESC _ ^F
1768 
1769 will do the job.
1770 
1771      A thoroughly unique ability of Multics Emacs is the ability to search for
1772 _^Hw_^Ho_^Hr_^Hd_^Hs as opposed to _^Hs_^Ht_^Hr_^Hi_^Hn_^Hg_^Hs, when required.  Suppose we had the sentence
1773 
1774      Yes, I know, Miss Smith's theater
1775      is the One for _^Hm_^He!
1776 
1777 Let us assume that the cursor was on a previous line, or in the word "Yes",
1778 and we wanted to find the word "is".  We could use String Search, ^S, and
1779 reply
1780 
1781      i s ESC
1782 
1783 to the prompt
1784 
1785      String Search:
1786 
1787 but this would get us to the "is" in "Miss", which is not what we want.
1788 We could search again, but there is a better way.  Use of the Word Search
1789 command, ^XW, will find a _^Hw_^Ho_^Hr_^Hd, not a part of a word.  If we had typed ^XW
1790 when trying to find the word "is", Emacs would have prompted:
1791 
1792      Word Search:
1793 
1794 We then type the word, "is", as we would have for String Search, and a
1795 carraige return.
1796 
1797      Word Search can find words regardless of capitalization or underlining.
1798 For instance, using Word Search to find the words "one" or "me" in the above
1799 sentence would find "One" and "_^Hm_^He".
1800 
1801      Word Search can also find _^Hs_^He_^Hq_^Hu_^He_^Hn_^Hc_^He_^Hs of words, which is to say, several
1802 sequential words, separated by any amount of punctuation or whitespace.  If
1803 the cursor were far above the above fragment, in the document in which it
1804 appeared, we could find our fragment by answering ^XW's prompt,
1805 
1806      Word Search: i know miss smith CR
1807 
1808 and the cursor will be left immediately after the "h" of "Smith", for the
1809 words:
1810 
1811      I know, Miss Smith
1812 
1813 appear in sequence.  The comma between "know" and "Miss", as well as all
1814 spaces, and the capitalization of I, Miss, and Smith, are ignored by Word
1815 Search.  In fact, we could have searched:
1816 
1817      Word Search: theater is the CR
1818 
1819 and the cursor would be left after the word "the", in the second line of the
1820 fragment.  The newline (carriage return) separating "theater" from "is" is
1821 simply whitespace, which is ignored by Word Search.  When we say that
1822 whitespace and punctuation is ignored by Word Search, we do not mean that
1823 having whitespace or punctuation  is the same as not having _^Ha_^Hn_^Hy: what _^Hi_^Hs meant
1824 is that any amount of whitespace or punctuation will be treated the same, as
1825 separating one word from the next.  Thus,
1826 
1827      ^XW jack knife CR
1828 
1829 will find
1830 
1831      jack knife
1832      Jack, knife
1833      J^H__^Ha_^Hc_^Hk... "KNIFE!!"
1834 
1835 but not
1836 
1837      jackknife
1838 
1839 which is one word, not two.
1840 
1841      Word Search can also help searching by searching for words that start
1842 with a given string.  This is useful for searching for long word.  To indicate
1843 that a word-prefix is being searched for, we type the first letters of the
1844 word followed by an asterisk, for example,
1845 
1846     anted*
1847 
1848 to search for "antediluvian"  We can use an abbreviated word in this way as
1849 part of a word-sequence being searched for, for example,
1850 
1851      ^XW the anted* era CR
1852 
1853 to search for
1854 
1855      T^H__^Hh_^He "A^H__^Hn_^Ht_^He_^Hd_^Hi_^Hl_^Hu_^Hv_^Hi_^Ha_^Hn" E^H__^Hr_^Ha
1856 
1857      Word Search is clearly an extremely powerful and useful command.  Like
1858 most other Emacs search commands, typing simply carriage return to its prompt,
1859 i.e., a null, or empty search string, re-uses the last search string.  Word
1860 Search searches from the current point in the buffer (where the cursor is) to
1861 the end of the buffer, indicating the usual
1862 
1863      Search Fails.
1864 
1865 with its characteristic beep if the word or words being searched for could not
1866 be found.  There is no reverse word search; however, Word Search with an
1867 argument, for example
1868 
1869      ESC 1 ^XW
1870 
1871 will search from the beginning of the buffer to the end.  A word of caution,
1872 however.   Because Word Search is such a powerful command that checks for so
1873 many different occurences, it can be slow, especially on a large file, and on
1874 a slow system.   Searching from the beginning of a file will almost always
1875 make it slower, taking a long time.  In general, the ordinary String Search
1876 (^S) should be used for best response if you can tell (as with other editors)
1877 what exact characters you are looking for; use word search when you do not
1878 know what characters you are looking for, but you do know what words.
1879 
1880      Perhaps the best example of a use for Word Search is the editing of an
1881 input segment to a text justifier, like compose or runoff, when you have a
1882 hard-copy of the output (.compout or .runoff) segment before you.  You can
1883 use Word Search to search for a group of words that you see in the output
1884 segment:  they will be found in the input segment, even if compose or runoff
1885 inserted or deleted many spaces or moved them around on different lines when
1886 filling or justifying text.
1887 
1888      We now summarize the various commands for manipulating words:
1889 
1890  Word Motion of cursor:
1891 
1892      ESC F          Move forward a word, to the end of the current word, or
1893                      (if now at the end of a word or between words) to the end
1894                      of the next word.
1895 
1896      ESC B          Move backward a word, to the beginning of the current
1897                      word, or (if now at the beginning of a word or between
1898                      words) to the beginning of the previous word.
1899 
1900 Deleting words and parts of words:
1901 
1902      ESC D          Delete forward from the cursor to the end of a word.  If
1903                      between words, this will delete the word to the right of
1904                      the cursor.
1905 
1906      ESC #          Delete backward from the cursor to the beginning of a
1907                      word.  If between words, this will delete the word to the
1908                      left of the cursor.
1909 
1910 Changing qualities of words:
1911      These commands apply to the word in which the cursor appears,
1912      or the word which IMMEDIATELY preceds the cursor:
1913 
1914      ESC U          Convert the word to all UPPERCASE.
1915 
1916      ESC L          CONVERT THE WORD TO ALL lowercase.
1917 
1918      ESC C          lowercase the word, and then give it
1919                      An Initial Capital Letter.
1920 
1921      ESC _          U^H__^Hn_^Hd_^He_^Hr_^Hl_^Hi_^Hn_^He the word.
1922 
1923      ESC -          De-underline _^Ht_^Hh_^He _^Hw_^Ho_^Hr_^Hd.
1924 
1925 Searching for words or groups of words:
1926 
1927      ^XW            Word Search.  Search forward for the word or sequence of
1928                     words in the search string.  The search string is ended by
1929                     the ESC character.
1930 
1931 ------------------------------------------------------------
1932 ============================================================
1933 Further Sections that should be written:
1934 
1935      Indentation and whitespace commands:
1936       ESC M, ESC I, ^O, ESC ^O, ^X^O, ^M action, ESC \, ESC ^.
1937       Fill prefix, fill mode. ESC Q, ESC ^I
1938 
1939      Text movers: ESC W, ESC ^W, ^XX, ^XG.
1940       Buffersmen: ^XH, ^XI, ^XK.
1941 
1942      2-window mode, ^X1 ^X2 ^X3 ^XO, ESC ^V.
1943 
1944      Sentences and Paragraphs:
1945       ESC A, ESC E, ESC K, ^X#. ESC [, ESC ], ESC H.
1946 
1947      Keyboard Macros, ^X(, ^X), ^X*, ^XE, ^XQ, save-macro.
1948 
1949      Miscellany: ^U, ^U^U, @, Comout (^X^E), \, ESC ^Y, Regexp
1950       and global searches.  Dired, Rmail. accept-msgs.
1951 
1952      Utter random miscellany: ^X^M, ^X^R, ^X^L, ^X^U, ^X ESC.
1953       ESC ^F, ESC ^B.
1954       make-wall-chart. set-screen-size. opt. "Hairy" searches.
1955 
1956      Printing terminal usage. ^XV.
1957 ------------------------------------------------------------
1958 ============================================================
1959 
1960      This document is not finished.  It may never be finished, because as fast
1961 as I can describe Emacs, it keeps growing.  Please look through emacs.info for
1962 whatever looks like it might interest you.  Look through fundamental-mode.info
1963 for any commands that look interesting.  Try them and see what they do.
1964 Make use of the builtin help facility, apropos, describe, and ESC ?.
1965 Dprint and look at any of the info segments you think may interest you; there
1966 is a complete list of available info segments
1967 in emacs.info in >doc>subsystem>emacs.
1968 
1969                               -Bernard S. Greenberg