Mercurial > vim
annotate runtime/doc/undo.txt @ 2231:aa6412cab544 vim73
Various improvements to undo file code to make it more robust.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 29 May 2010 20:33:07 +0200 |
parents | 81b83a19e127 |
children | dc2e5ec0500d |
rev | line source |
---|---|
2154
7c8c7c95a865
First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents:
2033
diff
changeset
|
1 *undo.txt* For Vim version 7.3a. Last change: 2009 Apr 12 |
7 | 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| | |
697 | 13 3. Undo blocks |undo-blocks| |
758 | 14 4. Undo branches |undo-branches| |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
15 5. Undo persistence |undo-persistence| |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
16 6. Remarks about undo |undo-remarks| |
7 | 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} | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
26 *E830* |
772 | 27 :u[ndo] {N} Jump to after change number {N}. See |undo-branches| |
28 for the meaning of {N}. {not in Vi} | |
29 | |
7 | 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 ============================================================================== | |
697 | 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 | |
839 | 91 *:undoj* *:undojoin* *E790* |
697 | 92 :undoj[oin] Join further changes with the previous undo block. |
93 Warning: Use with care, it may prevent the user from | |
839 | 94 properly undoing changes. Don't use this after undo |
95 or redo. | |
697 | 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 | |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
110 To do the opposite, break a change into two undo blocks, in Insert mode use |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
111 CTRL-G u. This is useful if you want an insert command to be undoable in |
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
112 parts. E.g., for each sentence. |i_CTRL-G_u| |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
113 Setting the value of 'undolevels' also breaks undo. Even when the new value |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
114 is equal to the old value. |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
115 |
697 | 116 ============================================================================== |
827 | 117 4. Undo branches *undo-branches* *undo-tree* |
758 | 118 |
793 | 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. | |
758 | 123 |
799 | 124 This is explained in the user manual: |usr_32.txt|. |
758 | 125 |
772 | 126 *:undol* *:undolist* |
127 :undol[ist] List the leafs in the tree of changes. Example: | |
128 number changes time ~ | |
856 | 129 4 10 10:34:11 |
130 18 4 11:01:46 | |
772 | 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. | |
138 | |
758 | 139 *g-* |
140 g- Go to older text state. With a count repeat that many | |
141 times. {not in Vi} | |
142 *:ea* *:earlier* | |
143 :earlier {count} Go to older text state {count} times. | |
144 :earlier {N}s Go to older text state about {N} seconds before. | |
145 :earlier {N}m Go to older text state about {N} minutes before. | |
146 :earlier {N}h Go to older text state about {N} hours before. | |
147 | |
148 *g+* | |
149 g+ Go to newer text state. With a count repeat that many | |
150 times. {not in Vi} | |
151 *:lat* *:later* | |
152 :later {count} Go to newer text state {count} times. | |
153 :later {N}s Go to newer text state about {N} seconds later. | |
154 :later {N}m Go to newer text state about {N} minutes later. | |
155 :later {N}h Go to newer text state about {N} hours later. | |
156 | |
772 | 157 |
758 | 158 Note that text states will become unreachable when undo information is cleared |
159 for 'undolevels'. | |
160 | |
161 Don't be surprised when moving through time shows multiple changes to take | |
162 place at a time. This happens when moving through the undo tree and then | |
163 making a new change. | |
164 | |
165 EXAMPLE | |
166 | |
167 Start with this text: | |
168 one two three ~ | |
169 | |
170 Delete the first word by pressing "x" three times: | |
171 ne two three ~ | |
172 e two three ~ | |
173 two three ~ | |
174 | |
175 Now undo that by pressing "u" three times: | |
176 e two three ~ | |
177 ne two three ~ | |
178 one two three ~ | |
179 | |
180 Delete the second word by pressing "x" three times: | |
181 one wo three ~ | |
182 one o three ~ | |
183 one three ~ | |
184 | |
185 Now undo that by using "g-" three times: | |
186 one o three ~ | |
187 one wo three ~ | |
188 two three ~ | |
189 | |
190 You are now back in the first undo branch, after deleting "one". Repeating | |
191 "g-" will now bring you back to the original text: | |
192 e two three ~ | |
193 ne two three ~ | |
194 one two three ~ | |
195 | |
196 Jump to the last change with ":later 1h": | |
197 one three ~ | |
198 | |
199 And back to the start again with ":earlier 1h": | |
200 one two three ~ | |
201 | |
202 | |
203 Note that using "u" and CTRL-R will not get you to all possible text states | |
204 while repeating "g-" and "g+" does. | |
205 | |
206 ============================================================================== | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
207 5. Undo persistence *undo-persistence* *persistent-undo* |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
208 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
209 When unloading a buffer Vim normally destroys the tree of undos created for |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
210 that buffer. By setting the 'undofile' option, Vim will automatically save |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
211 your undo history when you write a file and restore undo history when you edit |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
212 the file again. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
213 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
214 The 'undofile' option is checked after writing a file, before the BufWritePost |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
215 autocommands. If you want to control what files to write undo information |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
216 for, you can use a BufWritePre autocommand: > |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
217 au BufWritePre /tmp/* setlocal noundofile |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
218 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
219 Vim saves undo trees in a separate undo file, one for each edited file, using |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
220 a simple scheme that maps filesystem paths directly to undo files. Vim will |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
221 detect if an undo file is no longer synchronized with the file it was written |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
222 for (with a hash of the file contents) and ignore it when the file was changed |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
223 after the undo file was written, to prevent corruption. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
224 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
225 Undo files are normally saved in the same directory as the file. This can be |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
226 changed with the 'undodir' option. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
227 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
228 You can also save and restore undo histories by using ":wundo" and ":rundo" |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
229 respectively: |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
230 *:wundo* *:rundo* |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
231 :wundo[!] {file} |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
232 Write undo history to {file}. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
233 When {file} exists and it does not look like an undo file |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
234 (the magic number at the start of the file is wrong), then |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
235 this fails, unless the ! was added. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
236 If it exists and does look like an undo file it is |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
237 overwritten. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
238 {not in Vi} |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
239 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
240 :rundo {file} Read undo history from {file}. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
241 {not in Vi} |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
242 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
243 You can use these in autocommands to explicitly specify the name of the |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
244 history file. E.g.: > |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
245 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
246 au BufReadPost * rundo %:h/UNDO/%:t |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
247 au BufWritePost * wundo %:h/UNDO/%:t |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
248 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
249 You should keep 'undofile' off, otherwise you end up with two undo files for |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
250 every write. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
251 Note: I did not verify this always works! |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
252 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
253 Note that while reading/writing files and 'undofile' is set most errors will |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
254 be silent, unless 'verbose' is set. With :wundo and :rundo you will get more |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
255 error messages, e.g., when the file cannot be read or written. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
256 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
257 NOTE: undo files are never deleted by Vim. You need to delete them yourself. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
258 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
259 Reading an existing undo file may fail for several reasons: |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
260 *E822* It cannot be opened, because the file permissions don't allow it. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
261 *E823* The magic number at the start of the file doesn't match. This usually |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
262 means it is not an undo file. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
263 *E824* The version number of the undo file indicates that it's written by a |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
264 newer version of Vim. You need that newer version to open it. Don't |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
265 write the buffer if you want to keep the undo info in the file. |
2215
cccb71c2c5c1
Fix uninit memory read in undo code. Fix uint32_t in proto file.
Bram Moolenaar <bram@vim.org>
parents:
2214
diff
changeset
|
266 "File contents changed, cannot use undo info" |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
267 The file text differs from when the undo file was written. This means |
2215
cccb71c2c5c1
Fix uninit memory read in undo code. Fix uint32_t in proto file.
Bram Moolenaar <bram@vim.org>
parents:
2214
diff
changeset
|
268 the undo file cannot be used, it would corrupt the text. This also |
cccb71c2c5c1
Fix uninit memory read in undo code. Fix uint32_t in proto file.
Bram Moolenaar <bram@vim.org>
parents:
2214
diff
changeset
|
269 happens when 'encoding' differs from when the undo file was written. |
2231
aa6412cab544
Various improvements to undo file code to make it more robust.
Bram Moolenaar <bram@vim.org>
parents:
2223
diff
changeset
|
270 *E825* The undo file does not contain valid contents and cannot be used. |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
271 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
272 Writing an undo file may fail for these reasons: |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
273 *E828* The file to be written cannot be created. Perhaps you do not have |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
274 write permissions in the directory. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
275 "Will not overwrite with undo file, cannot read" |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
276 A file exists with the name of the undo file to be written, but it |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
277 cannot be read. You may want to delete this file or rename it. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
278 "Will not overwrite, this is not an undo file" |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
279 A file exists with the name of the undo file to be written, but it |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
280 does not start with the right magic number. You may want to delete |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
281 this file or rename it. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
282 *E829* An error occurred while writing the undo file. You may want to try |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
283 again. |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
284 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
285 ============================================================================== |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2154
diff
changeset
|
286 6. Remarks about undo *undo-remarks* |
7 | 287 |
288 The number of changes that are remembered is set with the 'undolevels' option. | |
289 If it is zero, the Vi-compatible way is always used. If it is negative no | |
290 undo is possible. Use this if you are running out of memory. | |
291 | |
292 Marks for the buffer ('a to 'z) are also saved and restored, together with the | |
293 text. {Vi does this a little bit different} | |
294 | |
295 When all changes have been undone, the buffer is not considered to be changed. | |
296 It is then possible to exit Vim with ":q" instead of ":q!" {not in Vi}. Note | |
297 that this is relative to the last write of the file. Typing "u" after ":w" | |
298 actually changes the buffer, compared to what was written, so the buffer is | |
299 considered changed then. | |
300 | |
301 When manual |folding| is being used, the folds are not saved and restored. | |
302 Only changes completely within a fold will keep the fold as it was, because | |
303 the first and last line of the fold don't change. | |
304 | |
305 The numbered registers can also be used for undoing deletes. Each time you | |
306 delete text, it is put into register "1. The contents of register "1 are | |
307 shifted to "2, etc. The contents of register "9 are lost. You can now get | |
308 back the most recent deleted text with the put command: '"1P'. (also, if the | |
309 deleted text was the result of the last delete or copy operation, 'P' or 'p' | |
310 also works as this puts the contents of the unnamed register). You can get | |
311 back the text of three deletes ago with '"3P'. | |
312 | |
313 *redo-register* | |
314 If you want to get back more than one part of deleted text, you can use a | |
315 special feature of the repeat command ".". It will increase the number of the | |
316 register used. So if you first do ""1P", the following "." will result in a | |
317 '"2P'. Repeating this will result in all numbered registers being inserted. | |
318 | |
319 Example: If you deleted text with 'dd....' it can be restored with | |
320 '"1P....'. | |
321 | |
322 If you don't know in which register the deleted text is, you can use the | |
323 :display command. An alternative is to try the first register with '"1P', and | |
324 if it is not what you want do 'u.'. This will remove the contents of the | |
325 first put, and repeat the put command for the second register. Repeat the | |
326 'u.' until you got what you want. | |
327 | |
328 vim:tw=78:ts=8:ft=help:norl: |