home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / undo.txt < prev    next >
Text File  |  1998-08-30  |  5KB  |  105 lines

  1. *undo.txt*      For Vim version 5.3.  Last modification: 1997 Dec 06
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Undo and redo                        *undo-redo*
  8.  
  9. 1. Undo and redo commands    |undo-commands|
  10. 2. Two ways of undo        |undo-two-ways|
  11. 3. Remarks about undo        |undo-remarks|
  12.  
  13. ==============================================================================
  14. 1. Undo and redo commands                *undo-commands*
  15.  
  16. <Undo>        or                    *undo* *<Undo>* *u*
  17. u            Undo [count] changes.  {Vi: only one level}
  18.  
  19.                             *:u* *:undo*
  20. :u[ndo]            Undo one change.  {Vi: only one level}
  21.  
  22.                             *CTRL-R*
  23. CTRL-R            Redo [count] changes which were undone.  {Vi: redraw
  24.             screen}
  25.  
  26.                             *:red* *:redo*
  27. :red[o]            Redo one change which was undone.  {Vi: no redo}
  28.  
  29.                             *U*
  30. U            Undo all latest changes on one line.  {Vi: while not
  31.             moved off of it}
  32.  
  33. The last changes are remembered.  You can use the undo and redo commands above
  34. to revert the text to how it was before each change.  You can also apply the
  35. changes again, getting back the text before the undo.
  36.  
  37. The "U" command is treated by undo/redo just like any other command.  Thus a
  38. "u" command undos a "U" command and a 'CTRL-R' command redoes it again.  When
  39. mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will
  40. restore the situation of a line to before the previous "U" command.  This may
  41. be confusing.  Try it out to get used to it.
  42.  
  43. ==============================================================================
  44. 2. Two ways of undo                    *undo-two-ways*
  45.  
  46. How undo and redo commands work depends on the 'u' flag in 'cpoptions'.
  47. There is the Vim way ('u' excluded) and the vi-compatible way ('u' included).
  48. In the Vim way, "uu" undoes two changes.  In the Vi-compatible way, "uu" does
  49. nothing (undoes an undo).
  50.  
  51. 'u' excluded, the Vim way:
  52. You can go back in time with the undo command.  You can then go forward again
  53. with the redo command.  If you make a new change after the undo command,
  54. the redo will not be possible anymore.
  55.  
  56. 'u' included, the Vi-compatible way:
  57. The undo command undoes the previous change, and also the previous undo command.
  58. The redo command repeats the previous undo command.  It does NOT repeat a
  59. change command, use "." for that.
  60.  
  61. Examples    Vim way            Vi-compatible way    ~
  62. "uu"        two times undo        no-op
  63. "u CTRL-R"    no-op            two times undo
  64.  
  65. Rationale:  Nvi uses the "." command instead of CTRL-R.  Unfortunately, this
  66.         is not Vi compatible.  For example "dwdwu." in Vi deletes two
  67.         words, in Nvi it does nothing.
  68.  
  69. ==============================================================================
  70. 3. Remarks about undo                    *undo-remarks*
  71.  
  72. The number of changes that are remembered is set with the 'undolevels' option.
  73. If it is zero, the Vi-compatible way is always used.  If it is negative no
  74. undo is possible.  Use this if you are running out of memory.
  75.  
  76. When all changes have been undone, the buffer is not considered to be changed.
  77. It is then possible to exit Vim with ":q" instead of ":q!".  {this is not in
  78. Vi} Note that this is relative to the last write of the file.  Typing "u"
  79. after ":w" actually changes the buffer, compared to what was written, so the
  80. buffer is considered changed then.
  81.  
  82. The numbered registers can also be used for undoing deletes.  Each time you
  83. delete text, it is put into register "1.  The contents of register "1 are
  84. shifted to "2, etc.  The contents of register "9 are lost.  You can now get
  85. back the most recent deleted text with the put command: '"1P'.  (also, if the
  86. deleted text was the result of the last delete or copy operation, 'P' or 'p'
  87. also works as this puts the contents of the unnamed register).  You can get
  88. back the text of three deletes ago with '"3P'.
  89.  
  90. If you want to get back more than one part of deleted text, you can use a
  91. special feature of the repeat command ".".  It will increase the number of the
  92. register used.  So if you first do ""1P", the following "." will result in a
  93. '"2P'.  Repeating this will result in all numbered registers being inserted.
  94.  
  95. Example:    If you deleted text with 'dd....' it can be restored with
  96.         '"1P....'.
  97.  
  98. If you don't know in which register the deleted text is, you can use the
  99. :display command.  An alternative is to try the first register with '"1P', and
  100. if it is not what you want do 'u.'.  This will remove the contents of the
  101. first put, and repeat the put command for the second register.  Repeat the
  102. 'u.' until you got what you want.
  103.  
  104.  vim:tw=78:ts=8:sw=8:
  105.