Bram Moolenaar | 4a74803 | 2010-09-30 21:47:56 +0200 | [diff] [blame] | 1 | *undo.txt* For Vim version 7.3. Last change: 2010 Sep 30 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Undo and redo *undo-redo* |
| 8 | |
| 9 | The basics are explained in section |02.5| of the user manual. |
| 10 | |
| 11 | 1. Undo and redo commands |undo-commands| |
| 12 | 2. Two ways of undo |undo-two-ways| |
Bram Moolenaar | e224ffa | 2006-03-01 00:01:28 +0000 | [diff] [blame] | 13 | 3. Undo blocks |undo-blocks| |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 14 | 4. Undo branches |undo-branches| |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 15 | 5. Undo persistence |undo-persistence| |
| 16 | 6. Remarks about undo |undo-remarks| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 17 | |
| 18 | ============================================================================== |
| 19 | 1. Undo and redo commands *undo-commands* |
| 20 | |
| 21 | <Undo> or *undo* *<Undo>* *u* |
| 22 | u Undo [count] changes. {Vi: only one level} |
| 23 | |
| 24 | *:u* *:un* *:undo* |
| 25 | :u[ndo] Undo one change. {Vi: only one level} |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 26 | *E830* |
Bram Moolenaar | efd2bf1 | 2006-03-16 21:41:35 +0000 | [diff] [blame] | 27 | :u[ndo] {N} Jump to after change number {N}. See |undo-branches| |
| 28 | for the meaning of {N}. {not in Vi} |
| 29 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 30 | *CTRL-R* |
| 31 | CTRL-R Redo [count] changes which were undone. {Vi: redraw |
| 32 | screen} |
| 33 | |
| 34 | *:red* *:redo* *redo* |
| 35 | :red[o] Redo one change which was undone. {Vi: no redo} |
| 36 | |
| 37 | *U* |
| 38 | U Undo all latest changes on one line. {Vi: while not |
| 39 | moved off of it} |
| 40 | |
| 41 | The last changes are remembered. You can use the undo and redo commands above |
| 42 | to revert the text to how it was before each change. You can also apply the |
| 43 | changes again, getting back the text before the undo. |
| 44 | |
| 45 | The "U" command is treated by undo/redo just like any other command. Thus a |
| 46 | "u" command undoes a "U" command and a 'CTRL-R' command redoes it again. When |
| 47 | mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will |
| 48 | restore the situation of a line to before the previous "U" command. This may |
| 49 | be confusing. Try it out to get used to it. |
| 50 | The "U" command will always mark the buffer as changed. When "U" changes the |
| 51 | buffer back to how it was without changes, it is still considered changed. |
| 52 | Use "u" to undo changes until the buffer becomes unchanged. |
| 53 | |
| 54 | ============================================================================== |
| 55 | 2. Two ways of undo *undo-two-ways* |
| 56 | |
| 57 | How undo and redo commands work depends on the 'u' flag in 'cpoptions'. |
| 58 | There is the Vim way ('u' excluded) and the vi-compatible way ('u' included). |
| 59 | In the Vim way, "uu" undoes two changes. In the Vi-compatible way, "uu" does |
| 60 | nothing (undoes an undo). |
| 61 | |
| 62 | 'u' excluded, the Vim way: |
| 63 | You can go back in time with the undo command. You can then go forward again |
| 64 | with the redo command. If you make a new change after the undo command, |
| 65 | the redo will not be possible anymore. |
| 66 | |
| 67 | 'u' included, the Vi-compatible way: |
| 68 | The undo command undoes the previous change, and also the previous undo command. |
| 69 | The redo command repeats the previous undo command. It does NOT repeat a |
| 70 | change command, use "." for that. |
| 71 | |
| 72 | Examples Vim way Vi-compatible way ~ |
| 73 | "uu" two times undo no-op |
| 74 | "u CTRL-R" no-op two times undo |
| 75 | |
| 76 | Rationale: Nvi uses the "." command instead of CTRL-R. Unfortunately, this |
| 77 | is not Vi compatible. For example "dwdwu." in Vi deletes two |
| 78 | words, in Nvi it does nothing. |
| 79 | |
| 80 | ============================================================================== |
Bram Moolenaar | e224ffa | 2006-03-01 00:01:28 +0000 | [diff] [blame] | 81 | 3. Undo blocks *undo-blocks* |
| 82 | |
| 83 | One undo command normally undoes a typed command, no matter how many changes |
| 84 | that command makes. This sequence of undo-able changes forms an undo block. |
| 85 | Thus if the typed key(s) call a function, all the commands in the function are |
| 86 | undone together. |
| 87 | |
| 88 | If you want to write a function or script that doesn't create a new undoable |
| 89 | change but joins in with the previous change use this command: |
| 90 | |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 91 | *:undoj* *:undojoin* *E790* |
Bram Moolenaar | e224ffa | 2006-03-01 00:01:28 +0000 | [diff] [blame] | 92 | :undoj[oin] Join further changes with the previous undo block. |
| 93 | Warning: Use with care, it may prevent the user from |
Bram Moolenaar | 57657d8 | 2006-04-21 22:12:41 +0000 | [diff] [blame] | 94 | properly undoing changes. Don't use this after undo |
| 95 | or redo. |
Bram Moolenaar | e224ffa | 2006-03-01 00:01:28 +0000 | [diff] [blame] | 96 | {not in Vi} |
| 97 | |
| 98 | This is most useful when you need to prompt the user halfway a change. For |
| 99 | example in a function that calls |getchar()|. Do make sure that there was a |
| 100 | related change before this that you must join with. |
| 101 | |
| 102 | This doesn't work by itself, because the next key press will start a new |
| 103 | change again. But you can do something like this: > |
| 104 | |
| 105 | :undojoin | delete |
| 106 | |
| 107 | After this an "u" command will undo the delete command and the previous |
| 108 | change. |
| 109 | |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 110 | To do the opposite, break a change into two undo blocks, in Insert mode use |
| 111 | CTRL-G u. This is useful if you want an insert command to be undoable in |
| 112 | parts. E.g., for each sentence. |i_CTRL-G_u| |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 113 | Setting the value of 'undolevels' also breaks undo. Even when the new value |
| 114 | is equal to the old value. |
Bram Moolenaar | 8f3f58f | 2010-01-06 20:52:26 +0100 | [diff] [blame] | 115 | |
Bram Moolenaar | e224ffa | 2006-03-01 00:01:28 +0000 | [diff] [blame] | 116 | ============================================================================== |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 117 | 4. Undo branches *undo-branches* *undo-tree* |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 118 | |
Bram Moolenaar | 76916e6 | 2006-03-21 21:23:25 +0000 | [diff] [blame] | 119 | Above we only discussed one line of undo/redo. But it is also possible to |
| 120 | branch off. This happens when you undo a few changes and then make a new |
| 121 | change. The undone changes become a branch. You can go to that branch with |
| 122 | the following commands. |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 123 | |
Bram Moolenaar | c01140a | 2006-03-24 22:21:52 +0000 | [diff] [blame] | 124 | This is explained in the user manual: |usr_32.txt|. |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 125 | |
Bram Moolenaar | efd2bf1 | 2006-03-16 21:41:35 +0000 | [diff] [blame] | 126 | *:undol* *:undolist* |
| 127 | :undol[ist] List the leafs in the tree of changes. Example: |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 128 | number changes time saved ~ |
Bram Moolenaar | c9b4b05 | 2006-04-30 18:54:39 +0000 | [diff] [blame] | 129 | 4 10 10:34:11 |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 130 | 18 4 11:01:46 7 |
Bram Moolenaar | efd2bf1 | 2006-03-16 21:41:35 +0000 | [diff] [blame] | 131 | |
| 132 | The "number" column is the change number. This number |
| 133 | continuously increases and can be used to identify a |
| 134 | specific undo-able change, see |:undo|. |
| 135 | The "changes" column is the number of changes to this |
| 136 | leaf from the root of the tree. |
| 137 | The "time" column is the time this change was made. |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 138 | The "saved" column specifies, if this change was |
| 139 | written to disk and which file write it was. This can |
Bram Moolenaar | 4a74803 | 2010-09-30 21:47:56 +0200 | [diff] [blame] | 140 | be used with the |:later| and |:earlier| commands. |
Bram Moolenaar | a800b42 | 2010-06-27 01:15:55 +0200 | [diff] [blame] | 141 | For more details use the |undotree()| function. |
Bram Moolenaar | efd2bf1 | 2006-03-16 21:41:35 +0000 | [diff] [blame] | 142 | |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 143 | *g-* |
| 144 | g- Go to older text state. With a count repeat that many |
| 145 | times. {not in Vi} |
| 146 | *:ea* *:earlier* |
| 147 | :earlier {count} Go to older text state {count} times. |
| 148 | :earlier {N}s Go to older text state about {N} seconds before. |
| 149 | :earlier {N}m Go to older text state about {N} minutes before. |
| 150 | :earlier {N}h Go to older text state about {N} hours before. |
Bram Moolenaar | 730cde9 | 2010-06-27 05:18:54 +0200 | [diff] [blame] | 151 | :earlier {N}d Go to older text state about {N} days before. |
| 152 | |
| 153 | :earlier {N}f Go to older text state {N} file writes before. |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 154 | When changes were made since the last write |
Bram Moolenaar | 730cde9 | 2010-06-27 05:18:54 +0200 | [diff] [blame] | 155 | ":earlier 1f" will revert the text to the state when |
| 156 | it was written. Otherwise it will go to the write |
| 157 | before that. |
| 158 | When at the state of the first file write, or when |
| 159 | the file was not written, ":earlier 1f" will go to |
| 160 | before the first change. |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 161 | |
| 162 | *g+* |
| 163 | g+ Go to newer text state. With a count repeat that many |
| 164 | times. {not in Vi} |
| 165 | *:lat* *:later* |
| 166 | :later {count} Go to newer text state {count} times. |
| 167 | :later {N}s Go to newer text state about {N} seconds later. |
| 168 | :later {N}m Go to newer text state about {N} minutes later. |
| 169 | :later {N}h Go to newer text state about {N} hours later. |
Bram Moolenaar | 730cde9 | 2010-06-27 05:18:54 +0200 | [diff] [blame] | 170 | :later {N}d Go to newer text state about {N} days later. |
| 171 | |
| 172 | :later {N}f Go to newer text state {N} file writes later. |
| 173 | When at the state of the last file write, ":later 1f" |
| 174 | will go to the newest text state. |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 175 | |
Bram Moolenaar | efd2bf1 | 2006-03-16 21:41:35 +0000 | [diff] [blame] | 176 | |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 177 | Note that text states will become unreachable when undo information is cleared |
| 178 | for 'undolevels'. |
| 179 | |
| 180 | Don't be surprised when moving through time shows multiple changes to take |
| 181 | place at a time. This happens when moving through the undo tree and then |
| 182 | making a new change. |
| 183 | |
| 184 | EXAMPLE |
| 185 | |
| 186 | Start with this text: |
| 187 | one two three ~ |
| 188 | |
| 189 | Delete the first word by pressing "x" three times: |
| 190 | ne two three ~ |
| 191 | e two three ~ |
| 192 | two three ~ |
| 193 | |
| 194 | Now undo that by pressing "u" three times: |
| 195 | e two three ~ |
| 196 | ne two three ~ |
| 197 | one two three ~ |
| 198 | |
| 199 | Delete the second word by pressing "x" three times: |
| 200 | one wo three ~ |
| 201 | one o three ~ |
| 202 | one three ~ |
| 203 | |
| 204 | Now undo that by using "g-" three times: |
| 205 | one o three ~ |
| 206 | one wo three ~ |
Bram Moolenaar | 1f4d4de | 2006-03-14 23:00:46 +0000 | [diff] [blame] | 207 | two three ~ |
| 208 | |
| 209 | You are now back in the first undo branch, after deleting "one". Repeating |
| 210 | "g-" will now bring you back to the original text: |
| 211 | e two three ~ |
| 212 | ne two three ~ |
| 213 | one two three ~ |
| 214 | |
| 215 | Jump to the last change with ":later 1h": |
| 216 | one three ~ |
| 217 | |
| 218 | And back to the start again with ":earlier 1h": |
| 219 | one two three ~ |
| 220 | |
| 221 | |
| 222 | Note that using "u" and CTRL-R will not get you to all possible text states |
| 223 | while repeating "g-" and "g+" does. |
| 224 | |
| 225 | ============================================================================== |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 226 | 5. Undo persistence *undo-persistence* *persistent-undo* |
| 227 | |
| 228 | When unloading a buffer Vim normally destroys the tree of undos created for |
| 229 | that buffer. By setting the 'undofile' option, Vim will automatically save |
| 230 | your undo history when you write a file and restore undo history when you edit |
| 231 | the file again. |
| 232 | |
| 233 | The 'undofile' option is checked after writing a file, before the BufWritePost |
| 234 | autocommands. If you want to control what files to write undo information |
| 235 | for, you can use a BufWritePre autocommand: > |
| 236 | au BufWritePre /tmp/* setlocal noundofile |
| 237 | |
| 238 | Vim saves undo trees in a separate undo file, one for each edited file, using |
| 239 | a simple scheme that maps filesystem paths directly to undo files. Vim will |
| 240 | detect if an undo file is no longer synchronized with the file it was written |
| 241 | for (with a hash of the file contents) and ignore it when the file was changed |
| 242 | after the undo file was written, to prevent corruption. |
| 243 | |
| 244 | Undo files are normally saved in the same directory as the file. This can be |
| 245 | changed with the 'undodir' option. |
| 246 | |
Bram Moolenaar | a3ff49f | 2010-05-30 22:48:02 +0200 | [diff] [blame] | 247 | When the file is encrypted, the text in the undo file is also crypted. The |
| 248 | same key and method is used. |encryption| |
| 249 | |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 250 | You can also save and restore undo histories by using ":wundo" and ":rundo" |
| 251 | respectively: |
| 252 | *:wundo* *:rundo* |
| 253 | :wundo[!] {file} |
| 254 | Write undo history to {file}. |
| 255 | When {file} exists and it does not look like an undo file |
| 256 | (the magic number at the start of the file is wrong), then |
| 257 | this fails, unless the ! was added. |
| 258 | If it exists and does look like an undo file it is |
| 259 | overwritten. |
| 260 | {not in Vi} |
| 261 | |
| 262 | :rundo {file} Read undo history from {file}. |
| 263 | {not in Vi} |
| 264 | |
| 265 | You can use these in autocommands to explicitly specify the name of the |
| 266 | history file. E.g.: > |
| 267 | |
Bram Moolenaar | a17d4c1 | 2010-05-30 18:30:36 +0200 | [diff] [blame] | 268 | au BufReadPost * call ReadUndo() |
| 269 | au BufWritePost * call WriteUndo() |
| 270 | func ReadUndo() |
| 271 | if filereadable(expand('%:h'). '/UNDO/' . expand('%:t')) |
| 272 | rundo %:h/UNDO/%:t |
| 273 | endif |
| 274 | endfunc |
| 275 | func WriteUndo() |
| 276 | let dirname = expand('%:h') . '/UNDO' |
| 277 | if !isdirectory(dirname) |
| 278 | call mkdir(dirname) |
| 279 | endif |
| 280 | wundo %:h/UNDO/%:t |
| 281 | endfunc |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 282 | |
| 283 | You should keep 'undofile' off, otherwise you end up with two undo files for |
| 284 | every write. |
Bram Moolenaar | a17d4c1 | 2010-05-30 18:30:36 +0200 | [diff] [blame] | 285 | |
| 286 | You can use the |undofile()| function to find out the file name that Vim would |
| 287 | use. |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 288 | |
| 289 | Note that while reading/writing files and 'undofile' is set most errors will |
| 290 | be silent, unless 'verbose' is set. With :wundo and :rundo you will get more |
| 291 | error messages, e.g., when the file cannot be read or written. |
| 292 | |
| 293 | NOTE: undo files are never deleted by Vim. You need to delete them yourself. |
| 294 | |
| 295 | Reading an existing undo file may fail for several reasons: |
| 296 | *E822* It cannot be opened, because the file permissions don't allow it. |
| 297 | *E823* The magic number at the start of the file doesn't match. This usually |
| 298 | means it is not an undo file. |
| 299 | *E824* The version number of the undo file indicates that it's written by a |
| 300 | newer version of Vim. You need that newer version to open it. Don't |
| 301 | write the buffer if you want to keep the undo info in the file. |
Bram Moolenaar | 7db5fc8 | 2010-05-24 11:59:29 +0200 | [diff] [blame] | 302 | "File contents changed, cannot use undo info" |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 303 | The file text differs from when the undo file was written. This means |
Bram Moolenaar | 7db5fc8 | 2010-05-24 11:59:29 +0200 | [diff] [blame] | 304 | the undo file cannot be used, it would corrupt the text. This also |
| 305 | happens when 'encoding' differs from when the undo file was written. |
Bram Moolenaar | 9db5806 | 2010-05-29 20:33:07 +0200 | [diff] [blame] | 306 | *E825* The undo file does not contain valid contents and cannot be used. |
Bram Moolenaar | 56be950 | 2010-06-06 14:20:26 +0200 | [diff] [blame] | 307 | *E826* The undo file is encrypted but decryption failed. |
| 308 | *E827* The undo file is encrypted but this version of Vim does not support |
| 309 | encryption. Open the file with another Vim. |
| 310 | *E832* The undo file is encrypted but 'key' is not set, the text file is not |
| 311 | encrypted. This would happen if the text file was written by Vim |
| 312 | encrypted at first, and later overwritten by not encrypted text. |
| 313 | You probably want to delete this undo file. |
Bram Moolenaar | 6ed8ed8 | 2010-05-30 20:40:11 +0200 | [diff] [blame] | 314 | "Not reading undo file, owner differs" |
| 315 | The undo file is owned by someone else than the owner of the text |
| 316 | file. For safety the undo file is not used. |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 317 | |
| 318 | Writing an undo file may fail for these reasons: |
| 319 | *E828* The file to be written cannot be created. Perhaps you do not have |
| 320 | write permissions in the directory. |
Bram Moolenaar | 6ed8ed8 | 2010-05-30 20:40:11 +0200 | [diff] [blame] | 321 | "Cannot write undo file in any directory in 'undodir'" |
| 322 | None of the directories in 'undodir' can be used. |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 323 | "Will not overwrite with undo file, cannot read" |
| 324 | A file exists with the name of the undo file to be written, but it |
| 325 | cannot be read. You may want to delete this file or rename it. |
| 326 | "Will not overwrite, this is not an undo file" |
| 327 | A file exists with the name of the undo file to be written, but it |
| 328 | does not start with the right magic number. You may want to delete |
| 329 | this file or rename it. |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 330 | "Skipping undo file write, nothing to undo" |
| 331 | There is no undo information to be written, nothing has been changed |
Bram Moolenaar | 6ed8ed8 | 2010-05-30 20:40:11 +0200 | [diff] [blame] | 332 | or 'undolevels' is negative. |
Bram Moolenaar | 55debbe | 2010-05-23 23:34:36 +0200 | [diff] [blame] | 333 | *E829* An error occurred while writing the undo file. You may want to try |
| 334 | again. |
| 335 | |
| 336 | ============================================================================== |
| 337 | 6. Remarks about undo *undo-remarks* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 338 | |
| 339 | The number of changes that are remembered is set with the 'undolevels' option. |
| 340 | If it is zero, the Vi-compatible way is always used. If it is negative no |
| 341 | undo is possible. Use this if you are running out of memory. |
| 342 | |
Bram Moolenaar | 945e2db | 2010-06-05 17:43:32 +0200 | [diff] [blame] | 343 | *clear-undo* |
| 344 | When you set 'undolevels' to -1 the undo information is not immediately |
| 345 | cleared, this happens at the next change. To force clearing the undo |
| 346 | information you can use these commands: > |
| 347 | :let old_undolevels = &undolevels |
| 348 | :set undolevels=-1 |
| 349 | :exe "normal a \<BS>\<Esc>" |
| 350 | :let &undolevels = old_undolevels |
| 351 | :unlet old_undolevels |
| 352 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 353 | Marks for the buffer ('a to 'z) are also saved and restored, together with the |
| 354 | text. {Vi does this a little bit different} |
| 355 | |
| 356 | When all changes have been undone, the buffer is not considered to be changed. |
| 357 | It is then possible to exit Vim with ":q" instead of ":q!" {not in Vi}. Note |
| 358 | that this is relative to the last write of the file. Typing "u" after ":w" |
| 359 | actually changes the buffer, compared to what was written, so the buffer is |
| 360 | considered changed then. |
| 361 | |
| 362 | When manual |folding| is being used, the folds are not saved and restored. |
| 363 | Only changes completely within a fold will keep the fold as it was, because |
| 364 | the first and last line of the fold don't change. |
| 365 | |
| 366 | The numbered registers can also be used for undoing deletes. Each time you |
| 367 | delete text, it is put into register "1. The contents of register "1 are |
| 368 | shifted to "2, etc. The contents of register "9 are lost. You can now get |
| 369 | back the most recent deleted text with the put command: '"1P'. (also, if the |
| 370 | deleted text was the result of the last delete or copy operation, 'P' or 'p' |
| 371 | also works as this puts the contents of the unnamed register). You can get |
| 372 | back the text of three deletes ago with '"3P'. |
| 373 | |
| 374 | *redo-register* |
| 375 | If you want to get back more than one part of deleted text, you can use a |
| 376 | special feature of the repeat command ".". It will increase the number of the |
| 377 | register used. So if you first do ""1P", the following "." will result in a |
| 378 | '"2P'. Repeating this will result in all numbered registers being inserted. |
| 379 | |
| 380 | Example: If you deleted text with 'dd....' it can be restored with |
| 381 | '"1P....'. |
| 382 | |
| 383 | If you don't know in which register the deleted text is, you can use the |
| 384 | :display command. An alternative is to try the first register with '"1P', and |
| 385 | if it is not what you want do 'u.'. This will remove the contents of the |
| 386 | first put, and repeat the put command for the second register. Repeat the |
| 387 | 'u.' until you got what you want. |
| 388 | |
| 389 | vim:tw=78:ts=8:ft=help:norl: |