TEXT   62

emacs windows

Guest on 22nd July 2022 02:13:36 AM

  1. * WINDOWS
  2. ---------
  4. Emacs can have several windows, each displaying its own text.  We will
  5. explain later on how to use multiple windows.  Right now we want to
  6. explain how to get rid of extra windows and go back to basic
  7. one-window editing.  It is simple:
  9.         C-x 1   One window (i.e., kill all other windows).
  11. That is Control-x followed by the digit 1.  C-x 1 expands the window
  12. which contains the cursor, to occupy the full screen.  It deletes all
  13. other windows.
  15. >> Move the cursor to this line and type C-u 0 C-l.
  16. >> Type Control-h k Control-f.
  17.    See how this window shrinks, while a new one appears
  18.    to display documentation on the Control-f command.
  20. >> Type C-x 1 and see the documentation listing window disappear.
  22. This command is unlike the other commands you have learned in that it
  23. consists of two characters.  It starts with the character Control-x.
  24. There is a whole series of commands that start with Control-x; many of
  25. them have to do with windows, files, buffers, and related things.
  26. These commands are two, three or four characters long.
  29. --------------------
  31. If Emacs stops responding to your commands, you can stop it safely by
  32. typing C-g.  You can use C-g to stop a command which is taking too
  33. long to execute.
  35. You can also use C-g to discard a numeric argument or the beginning of
  36. a command that you do not want to finish.
  38. >> Type C-u 100 to make a numeric arg of 100, then type C-g.
  39.    Now type C-f.  It should move just one character,
  40.    because you canceled the argument with C-g.
  42. If you have typed an <ESC> by mistake, you can get rid of it
  43. with a C-g.
  45. You've now learned the most basic way of typing something in
  46. Emacs and correcting errors.  You can delete by words or lines
  47. as well.  Here is a summary of the delete operations:
  49.         <Delete>     delete the character just before the cursor
  50.         C-d          delete the next character after the cursor
  52.         M-<Delete>   kill the word immediately before the cursor
  53.         M-d          kill the next word after the cursor
  55.         C-k          kill from the cursor position to end of line
  56.         M-k          kill to the end of the current sentence
  58. Notice that <Delete> and C-d vs M-<Delete> and M-d extend the parallel
  59. started by C-f and M-f (well, <Delete> is not really a control
  60. character, but let's not worry about that).  C-k and M-k are like C-e
  61. and M-e, sort of, in that lines are opposite sentences.
  63. When you delete more than one character at a time, Emacs saves the
  64. deleted text so that you can bring it back.  Bringing back killed text
  65. is called "yanking".  You can yank the killed text either at the same
  66. place where it was killed, or at some other place in the text.  You
  67. can yank the text several times in order to make multiple copies of
  68. it.  The command to yank is C-y.
  70. Note that the difference between "Killing" and "Deleting" something is
  71. that "Killed" things can be yanked back, and "Deleted" things cannot.
  72. Generally, the commands that can remove a lot of text save the text,
  73. while the commands that delete just one character, or just blank lines
  74. and spaces, do not save the deleted text.
  76. >> Move the cursor to the  beginning of a line which is not empty.
  77.    Then type C-k to kill the text on that line.
  78. >> Type C-k a second time.  You'll see that it kills the Newline
  79.    which follows that line.
  81. Note that a single C-k kills the contents of the line, and a second
  82. C-k kills the line itself, and make all the other lines move up.  C-k
  83. treats a numeric argument specially: it kills that many lines AND
  84. their contents.  This is not mere repetition.  C-u 2 C-k kills two
  85. lines and their newlines; typing C-k twice would not do that.
  87. To retrieve the last killed text and put it where the cursor currently
  88. is, type C-y.
  90. >> Try it; type C-y to yank the text back.
  92. Think of C-y as if you were yanking something back that someone took
  93. away from you.  Notice that if you do several C-k's in a row, all of
  94. the killed text is saved together, so that one C-y will yank all of
  95. the lines.
  97. >> Do this now, type C-k several times.
  99. Now to retrieve that killed text:
  101. >> Type C-y.  Then move the cursor down a few lines and type C-y
  102.    again.  You now see how to copy some text.
  104. What do you do if you have some text you want to yank back, and then
  105. you kill something else?  C-y would yank the more recent kill.  But
  106. the previous text is not lost.  You can get back to it using the M-y
  107. command.  After you have done C-y to get the most recent kill, typing
  108. M-y replaces that yanked text with the previous kill.  Typing M-y
  109. again and again brings in earlier and earlier kills.  When you have
  110. reached the text you are looking for, you do not have to do anything to
  111. keep it.  Just go on with your editing, leaving the yanked text where
  112. it is.
  114. If you M-y enough times, you come back to the starting point (the most
  115. recent kill).
  117. >> Kill a line, move around, kill another line.
  118.    Then do C-y to get back the second killed line.
  119.    Then do M-y and it will be replaced by the first killed line.
  120.    Do more M-y's and see what you get.  Keep doing them until
  121.    the second kill line comes back, and then a few more.
  122.    If you like, you can try giving M-y positive and negative
  123.    arguments.
  126. * UNDO
  127. ------
  129. If you make a change to the text, and then decide that it was a
  130. mistake, you can undo the change with the undo command, C-x u.
  132. Normally, C-x u undoes the changes made by one command; if you repeat
  133. the C-x u several times in a row, each repetition undoes one
  134. additional command.
  136. But there are two exceptions: commands that do not change the text do
  137. not count (this includes cursor motion commands and scrolling
  138. command), and self-inserting characters are usually handled in groups
  139. of up to 20.  (This is to reduce the number of C-x u's you have to
  140. type to undo insertion of text.)
  142. >> Kill this line with C-k, then type C-x u and it should reappear.
  144. C-_ is an alternative undo command; it works just the same as C-x u,
  145. but it is easier to type several times in a row.  The disadvantage of
  146. C-_ is that on some keyboards it is not obvious how to type it.  That
  147. is why we provide C-x u as well.  On some terminals, you can type C-_
  148. by typing / while holding down CONTROL.
  150. A numeric argument to C-_ or C-x u acts as a repeat count.

Raw Paste

Login or Register to edit or fork this paste. It's free.