undo.texi 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. @node Undo, Minibuffer, Basic, Top
  2. @chapter Undoing Changes
  3. @cindex undo
  4. @cindex mistakes, correcting
  5. Emacs allows you to undo all changes you make to the text of a buffer,
  6. up to a certain amount of change (8000 characters). Each buffer records
  7. changes individually, and the undo command always applies to the
  8. current buffer. Usually each editing command makes a separate entry
  9. in the undo records, but some commands such as @code{query-replace}
  10. make many entries, and very simple commands such as self-inserting
  11. characters are often grouped to make undoing less tedious.
  12. @table @kbd
  13. @item C-x u
  14. Undo one batch of changes (usually, one command's worth) (@code{undo}).
  15. @item C-_
  16. The same.
  17. @end table
  18. @kindex C-x u
  19. @kindex C-_
  20. @findex undo
  21. The command @kbd{C-x u} or @kbd{C-_} allows you to undo changes. The
  22. first time you give this command, it undoes the last change. Point
  23. moves to the text affected by the undo, so you can see what was undone.
  24. Consecutive repetitions of the @kbd{C-_} or @kbd{C-x u} commands undo
  25. earlier and earlier changes, back to the limit of what has been
  26. recorded. If all recorded changes have already been undone, the undo
  27. command prints an error message and does nothing.
  28. Any command other than an undo command breaks the sequence of undo
  29. commands. Starting at this moment, the previous undo commands are
  30. considered ordinary changes that can themselves be undone. Thus, you can
  31. redo changes you have undone by typing @kbd{C-f} or any other command
  32. that have no important effect, and then using more undo commands.
  33. If you notice that a buffer has been modified accidentally, the
  34. easiest way to recover is to type @kbd{C-_} repeatedly until the stars
  35. disappear from the front of the mode line. When that happens, all the
  36. modifications you made have been canceled. If you do not remember
  37. whether you changed the buffer deliberately, type @kbd{C-_} once. When
  38. you see Emacs undo the last change you made, you probably remember why you
  39. made it. If the change was an accident, leave it undone. If it was
  40. deliberate, redo the change as described in the preceding paragraph.
  41. Whenever an undo command makes the stars disappear from the mode line,
  42. the buffer contents is the same as it was when the file was last read in
  43. or saved.
  44. Not all buffers record undo information. Buffers whose names start with
  45. spaces don't; these buffers are used internally by Emacs and its extensions
  46. to hold text that users don't normally look at or edit. Minibuffers,
  47. help buffers, and documentation buffers also don't record undo information.
  48. Emacs can remember at most 8000 or so characters of deleted or
  49. modified text in any one buffer for reinsertion by the undo command.
  50. There is also a limit on the number of individual insert, delete, or
  51. change actions that Emacs can remember.
  52. There are two keys to run the @code{undo} command, @kbd{C-x u} and
  53. @kbd{C-_}, because on some keyboards, it is not obvious how to type
  54. @kbd{C-_}. @kbd{C-x u} is an alternative you can type in the same
  55. fashion on any terminal.