This file is indexed.

/usr/share/doc/vim/html/undo.html is in vim-doc 2:8.0.1453-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: undo</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: undo</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>

<HR>
<PRE>

*<A NAME="undo.txt"></A><B>undo.txt</B>*      For Vim version 8.0.  Last change: 2014 May 24


		  VIM REFERENCE MANUAL    by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>



Undo and <A HREF="#redo">redo</A>						*<A NAME="undo-redo"></A><B>undo-redo</B>*

The basics are explained in section |<A HREF="usr_02.html#02.5">02.5</A>| of the user manual.

1. Undo and <A HREF="#redo">redo</A> commands	|<A HREF="#undo-commands">undo-commands</A>|
2. Two ways of undo		|<A HREF="#undo-two-ways">undo-two-ways</A>|
3. Undo blocks			|<A HREF="#undo-blocks">undo-blocks</A>|
4. Undo branches		|<A HREF="#undo-branches">undo-branches</A>|
5. Undo persistence		|<A HREF="#undo-persistence">undo-persistence</A>|
6. Remarks about undo		|<A HREF="#undo-remarks">undo-remarks</A>|

==============================================================================

1. Undo and <A HREF="#redo">redo</A> commands				*<A NAME="undo-commands"></A><B>undo-commands</B>*


<A HREF="#&lt;Undo&gt;">&lt;Undo&gt;</A>		or					*<A NAME="undo"></A><B>undo</B>* *<A NAME="&lt;Undo&gt;"></A><B>&lt;Undo&gt;</B>* *<A NAME="u"></A><B>u</B>*
<A HREF="#u">u</A>			Undo <A HREF="intro.html#[count]">[count]</A> changes.  {Vi: only one level}


							*<A NAME=":u"></A><B>:u</B>* *<A NAME=":un"></A><B>:un</B>* *<A NAME=":undo"></A><B>:undo</B>*
:u[ndo]			Undo one change.  {Vi: only one level}

								*<A NAME="E830"></A><B>E830</B>*
:u[ndo] {N}		Jump to after change number {N}.  See |<A HREF="#undo-branches">undo-branches</A>|
			for the meaning of {N}.  {not in Vi}


							*<A NAME="CTRL-R"></A><B>CTRL-R</B>*
<A HREF="#CTRL-R">CTRL-R</A>			Redo <A HREF="intro.html#[count]">[count]</A> changes which were undone.  {Vi: redraw
			screen}


							*<A NAME=":red"></A><B>:red</B>* *<A NAME=":redo"></A><B>:redo</B>* *<A NAME="redo"></A><B>redo</B>*
:red[o]			Redo one change which was undone.  {Vi: no redo}


							*<A NAME="U"></A><B>U</B>*
<A HREF="#U">U</A>			Undo all latest changes on one line, the line where
			the latest change was made. |<A HREF="#U">U</A>| itself also counts <A HREF="motion.html#as">as</A>
			a change, and thus |<A HREF="#U">U</A>| undoes a previous |<A HREF="#U">U</A>|.
			{Vi: while not moved off of the last modified line}

The last changes are remembered.  You can use the <A HREF="#undo">undo</A> and <A HREF="#redo">redo</A> commands above
to revert the text to how <A HREF="motion.html#it">it</A> was before each change.  You can also apply the
changes again, getting back the text before the <A HREF="#undo">undo</A>.

The &quot;<A HREF="#U">U</A>&quot; command is treated by undo/redo just like any other command.  Thus a
&quot;<A HREF="#u">u</A>&quot; command undoes a &quot;<A HREF="#U">U</A>&quot; command and a '<A HREF="#CTRL-R">CTRL-R</A>' command redoes <A HREF="motion.html#it">it</A> again.  When
mixing &quot;<A HREF="#U">U</A>&quot;, &quot;<A HREF="#u">u</A>&quot; and '<A HREF="#CTRL-R">CTRL-R</A>' you will notice that the &quot;<A HREF="#U">U</A>&quot; command will
restore the situation of a line to before the previous &quot;<A HREF="#U">U</A>&quot; command.  This may
be confusing.  Try <A HREF="motion.html#it">it</A> out to get used to <A HREF="motion.html#it">it</A>.
The &quot;<A HREF="#U">U</A>&quot; command will always <A HREF="motion.html#mark">mark</A> the buffer <A HREF="motion.html#as">as</A> changed.  When &quot;<A HREF="#U">U</A>&quot; changes the
buffer back to how <A HREF="motion.html#it">it</A> was without changes, <A HREF="motion.html#it">it</A> is still considered changed.
Use &quot;<A HREF="#u">u</A>&quot; to <A HREF="#undo">undo</A> changes until the buffer becomes unchanged.

==============================================================================

2. Two ways of <A HREF="#undo">undo</A>					*<A NAME="undo-two-ways"></A><B>undo-two-ways</B>*

How <A HREF="#undo">undo</A> and <A HREF="#redo">redo</A> commands work depends on the '<A HREF="#u">u</A>' flag in <A HREF="options.html#'cpoptions'">'cpoptions'</A>.
There is the Vim way ('u' excluded) and the Vi-compatible way ('u' included).
In the Vim way, &quot;uu&quot; undoes two changes.  In the Vi-compatible way, &quot;uu&quot; does
nothing (undoes an <A HREF="#undo">undo</A>).

'<A HREF="#u">u</A>' excluded, the Vim way:
You can go back in time with the <A HREF="#undo">undo</A> command.  You can then go forward again
with the <A HREF="#redo">redo</A> command.  If you make a new change after the <A HREF="#undo">undo</A> command,
the <A HREF="#redo">redo</A> will not be possible anymore.

'<A HREF="#u">u</A>' included, the Vi-compatible way:
The <A HREF="#undo">undo</A> command undoes the previous change, and also the previous <A HREF="#undo">undo</A> command.
The <A HREF="#redo">redo</A> command repeats the previous <A HREF="#undo">undo</A> command.  It does NOT repeat a
change command, use &quot;<A HREF="repeat.html#.">.</A>&quot; for that.

<B><FONT COLOR="PURPLE">Examples	Vim way			Vi-compatible way	</FONT></B>
&quot;uu&quot;		two times <A HREF="#undo">undo</A>		no-op
&quot;<A HREF="#u">u</A> CTRL-R&quot;	no-op			two times <A HREF="#undo">undo</A>

Rationale:  <A HREF="intro.html#Nvi">Nvi</A> uses the &quot;<A HREF="repeat.html#.">.</A>&quot; command instead of <A HREF="#CTRL-R">CTRL-R</A>.  Unfortunately, this
	    is not <A HREF="intro.html#Vi">Vi</A> compatible.  For example &quot;dwdwu.&quot; in <A HREF="intro.html#Vi">Vi</A> deletes two
	    words, in <A HREF="intro.html#Nvi">Nvi</A> <A HREF="motion.html#it">it</A> does nothing.

==============================================================================

3. Undo blocks						*<A NAME="undo-blocks"></A><B>undo-blocks</B>*

One <A HREF="#undo">undo</A> command normally undoes a typed command, no matter how many changes
that command makes.  This sequence of undo-able changes forms an <A HREF="#undo">undo</A> block.
Thus if the typed key(s) call a function, all the commands in the function are
undone together.

If you want to write a function or <A HREF="usr_41.html#script">script</A> that doesn't create a new undoable
change but joins in with the previous change use this command:


						*<A NAME=":undoj"></A><B>:undoj</B>* *<A NAME=":undojoin"></A><B>:undojoin</B>* *<A NAME="E790"></A><B>E790</B>*
:undoj[oin]		Join further changes with the previous <A HREF="#undo">undo</A> block.
			Warning: Use with care, <A HREF="motion.html#it">it</A> may prevent the user from
			properly undoing changes.  Don't use this after <A HREF="#undo">undo</A>
			or <A HREF="#redo">redo</A>.
			{not in Vi}

This is most useful when you need to prompt the user halfway through a change.
For example in a function that calls |<A HREF="eval.html#getchar()">getchar()</A>|.  Do make sure that there was
a related change before this that you must join with.

This doesn't work by itself, because the next key press will start a new
change again.  But you can <A HREF="diff.html#do">do</A> something like this:

<B>	:undojoin | delete</B>

After this an &quot;<A HREF="#u">u</A>&quot; command will <A HREF="#undo">undo</A> the delete command and the previous
change.

To <A HREF="diff.html#do">do</A> the opposite, break a change into two <A HREF="#undo">undo</A> blocks, in <A HREF="insert.html#Insert">Insert</A> mode use
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="#u">u</A>.  This is useful if you want an insert command to be undoable in
parts.  E.g., for each <A HREF="motion.html#sentence">sentence</A>.  |<A HREF="insert.html#i_CTRL-G_u">i_CTRL-G_u</A>|
Setting the value of <A HREF="options.html#'undolevels'">'undolevels'</A> also breaks <A HREF="#undo">undo</A>.  Even when the new value
is equal to the old value.

==============================================================================

4. Undo branches				*<A NAME="undo-branches"></A><B>undo-branches</B>* *<A NAME="undo-tree"></A><B>undo-tree</B>*

Above we only discussed one line of undo/redo.  But <A HREF="motion.html#it">it</A> is also possible to
branch off.  This happens when you <A HREF="#undo">undo</A> a few changes and then make a new
change.  The undone changes become a branch.  You can go to that branch with
the following commands.

This is explained in the user manual: |<A HREF="usr_32.html">usr_32.txt</A>|.


							*<A NAME=":undol"></A><B>:undol</B>* *<A NAME=":undolist"></A><B>:undolist</B>*
:undol[ist]		<A HREF="eval.html#List">List</A> the leafs in the tree of changes.  Example:
<B><FONT COLOR="PURPLE">			   number changes  when               saved </FONT></B>
			       88      88  2010/01/04 14:25:53
			      108     107  08/07 12:47:51
			      136      46  13:33:01             7
			      166     164  3 seconds ago

			The &quot;number&quot; column is the change number.  This number
			continuously increases and can be used to identify a
			specific undo-able change, see |<A HREF="#:undo">:undo</A>|.
			The &quot;changes&quot; column is the number of changes to this
			leaf from the root of the tree.
			The &quot;when&quot; column is the date and time when this
			change was made.  The four possible formats are:
			    N seconds ago
			    HH:MM:SS             hour, minute, seconds
			    MM/DD HH:MM:SS       idem, with month and day
			    YYYY/MM/DD HH:MM:SS  idem, with year
			The &quot;saved&quot; column specifies, if this change was
			written to disk and which file write <A HREF="motion.html#it">it</A> was. This can
			be used with the |<A HREF="#:later">:later</A>| and |<A HREF="#:earlier">:earlier</A>| commands.
			For more details use the |<A HREF="eval.html#undotree()">undotree()</A>| function.


							*<A NAME="g-"></A><B>g-</B>*
<A HREF="#g-">g-</A>			Go to older text state.  With a <A HREF="intro.html#count">count</A> repeat that many
			times.  {not in Vi}

							*<A NAME=":ea"></A><B>:ea</B>* *<A NAME=":earlier"></A><B>:earlier</B>*
<A HREF="#:earlier">:earlier</A> {count}	Go to older text state {count} times.
<A HREF="#:earlier">:earlier</A> {N}s		Go to older text state about {N} seconds before.
<A HREF="#:earlier">:earlier</A> {N}m		Go to older text state about {N} minutes before.
<A HREF="#:earlier">:earlier</A> {N}h		Go to older text state about {N} hours before.
<A HREF="#:earlier">:earlier</A> {N}d		Go to older text state about {N} days before.

<A HREF="#:earlier">:earlier</A> {N}f		Go to older text state {N} file writes before.
			When changes were made since the last write
			&quot;<A HREF="#:earlier">:earlier</A> 1f&quot; will revert the text to the state when
			<A HREF="motion.html#it">it</A> was written.  Otherwise <A HREF="motion.html#it">it</A> will go to the write
			before that.
			When at the state of the first file write, or when
			the file was not written, &quot;<A HREF="#:earlier">:earlier</A> 1f&quot; will go to
			before the first change.


							*<A NAME="g+"></A><B>g+</B>*
<A HREF="#g+">g+</A>			Go to newer text state.  With a <A HREF="intro.html#count">count</A> repeat that many
			times.  {not in Vi}

							*<A NAME=":lat"></A><B>:lat</B>* *<A NAME=":later"></A><B>:later</B>*
<A HREF="#:later">:later</A> {count}		Go to newer text state {count} times.
<A HREF="#:later">:later</A> {N}s		Go to newer text state about {N} seconds later.
<A HREF="#:later">:later</A> {N}m		Go to newer text state about {N} minutes later.
<A HREF="#:later">:later</A> {N}h		Go to newer text state about {N} hours later.
<A HREF="#:later">:later</A> {N}d		Go to newer text state about {N} days later.

<A HREF="#:later">:later</A> {N}f		Go to newer text state {N} file writes later.
			When at the state of the last file write, &quot;<A HREF="#:later">:later</A> 1f&quot;
			will go to the newest text state.


Note that text states will become unreachable when <A HREF="#undo">undo</A> information is cleared
for <A HREF="options.html#'undolevels'">'undolevels'</A>.

Don't be surprised when moving through time shows multiple changes to take
place at a time.  This happens when moving through the <A HREF="#undo">undo</A> tree and then
making a new change.

EXAMPLE

Start with this text:
<B><FONT COLOR="PURPLE">	one two three </FONT></B>

Delete the first <A HREF="motion.html#word">word</A> by pressing &quot;<A HREF="change.html#x">x</A>&quot; three times:
<B><FONT COLOR="PURPLE">	ne two three </FONT></B>
<B><FONT COLOR="PURPLE">	e two three </FONT></B>
<B><FONT COLOR="PURPLE">	 two three </FONT></B>

Now <A HREF="#undo">undo</A> that by pressing &quot;<A HREF="#u">u</A>&quot; three times:
<B><FONT COLOR="PURPLE">	e two three </FONT></B>
<B><FONT COLOR="PURPLE">	ne two three </FONT></B>
<B><FONT COLOR="PURPLE">	one two three </FONT></B>

Delete the second <A HREF="motion.html#word">word</A> by pressing &quot;<A HREF="change.html#x">x</A>&quot; three times:
<B><FONT COLOR="PURPLE">	one wo three </FONT></B>
<B><FONT COLOR="PURPLE">	one o three </FONT></B>
<B><FONT COLOR="PURPLE">	one  three </FONT></B>

Now <A HREF="#undo">undo</A> that by using &quot;<A HREF="#g-">g-</A>&quot; three times:
<B><FONT COLOR="PURPLE">	one o three </FONT></B>
<B><FONT COLOR="PURPLE">	one wo three </FONT></B>
<B><FONT COLOR="PURPLE">	 two three </FONT></B>

You are now back in the first <A HREF="#undo">undo</A> branch, after <A HREF="change.html#deleting">deleting</A> &quot;one&quot;.  Repeating
&quot;<A HREF="#g-">g-</A>&quot; will now bring you back to the original text:
<B><FONT COLOR="PURPLE">	e two three </FONT></B>
<B><FONT COLOR="PURPLE">	ne two three </FONT></B>
<B><FONT COLOR="PURPLE">	one two three </FONT></B>

Jump to the last change with &quot;<A HREF="#:later">:later</A> 1h&quot;:
<B><FONT COLOR="PURPLE">	one  three </FONT></B>

And back to the start again with &quot;<A HREF="#:earlier">:earlier</A> 1h&quot;:
<B><FONT COLOR="PURPLE">	one two three </FONT></B>


Note that using &quot;<A HREF="#u">u</A>&quot; and <A HREF="#CTRL-R">CTRL-R</A> will not get you to all possible text states
while <A HREF="repeat.html#repeating">repeating</A> &quot;<A HREF="#g-">g-</A>&quot; and &quot;<A HREF="#g+">g+</A>&quot; does.

==============================================================================

5. Undo persistence		*<A NAME="undo-persistence"></A><B>undo-persistence</B>* *<A NAME="persistent-undo"></A><B>persistent-undo</B>*

When unloading a buffer Vim normally destroys the tree of undos created for
that buffer.  By setting the <A HREF="options.html#'undofile'">'undofile'</A> option, Vim will automatically save
your <A HREF="#undo">undo</A> <A HREF="cmdline.html#history">history</A> when you write a file and restore <A HREF="#undo">undo</A> <A HREF="cmdline.html#history">history</A> when you edit
the file again.

The <A HREF="options.html#'undofile'">'undofile'</A> option is checked after <A HREF="editing.html#writing">writing</A> a file, before the <A HREF="autocmd.html#BufWritePost">BufWritePost</A>
autocommands.  If you want to <A HREF="intro.html#control">control</A> what files to write <A HREF="#undo">undo</A> information
for, you can use a <A HREF="autocmd.html#BufWritePre">BufWritePre</A> <A HREF="autocmd.html#autocommand">autocommand</A>:
<B>	au BufWritePre /tmp/* setlocal noundofile</B>

Vim saves <A HREF="#undo">undo</A> trees in a separate <A HREF="#undo">undo</A> file, one for each edited file, using
a simple scheme that maps filesystem paths directly to <A HREF="#undo">undo</A> files. Vim will
detect if an <A HREF="#undo">undo</A> file is no longer synchronized with the file <A HREF="motion.html#it">it</A> was written
for (with a hash of the file contents) and ignore <A HREF="motion.html#it">it</A> when the file was changed
after the <A HREF="#undo">undo</A> file was written, to prevent corruption.  An <A HREF="#undo">undo</A> file is also
ignored if its owner differs from the owner of the edited file, except when
the owner of the <A HREF="#undo">undo</A> file is the current user.  Set <A HREF="options.html#'verbose'">'verbose'</A> to get a
message about that when opening a file.

Undo files are normally saved in the same directory <A HREF="motion.html#as">as</A> the file.  This can be
changed with the <A HREF="options.html#'undodir'">'undodir'</A> option.

When the file is encrypted, the text in the <A HREF="#undo">undo</A> file is also crypted.  The
same key and method is used. |<A HREF="editing.html#encryption">encryption</A>|

You can also save and restore <A HREF="#undo">undo</A> histories by using &quot;<A HREF="#:wundo">:wundo</A>&quot; and &quot;<A HREF="#:rundo">:rundo</A>&quot;
respectively:

							*<A NAME=":wundo"></A><B>:wundo</B>* *<A NAME=":rundo"></A><B>:rundo</B>*
:wundo[!] <A HREF="editing.html#{file}">{file}</A>
		Write <A HREF="#undo">undo</A> <A HREF="cmdline.html#history">history</A> to <A HREF="editing.html#{file}">{file}</A>.
		When <A HREF="editing.html#{file}">{file}</A> exists and <A HREF="motion.html#it">it</A> does not look like an <A HREF="#undo">undo</A> file
		(the magic number at the start of the file is wrong), then
		this fails, unless the ! was added.
		If <A HREF="motion.html#it">it</A> exists and does look like an <A HREF="#undo">undo</A> file <A HREF="motion.html#it">it</A> is
		overwritten. If there is no undo-history, nothing will be 
		written.
		Implementation detail: Overwriting happens by first <A HREF="change.html#deleting">deleting</A>
		the existing file and then creating a new file with the same
		name. So <A HREF="motion.html#it">it</A> is not possible to overwrite an existing undofile
		in a write-protected directory.
		{not in Vi}

<A HREF="#:rundo">:rundo</A> <A HREF="editing.html#{file}">{file}</A>	Read <A HREF="#undo">undo</A> <A HREF="cmdline.html#history">history</A> from <A HREF="editing.html#{file}">{file}</A>.
		{not in Vi}

You can use these in autocommands to explicitly specify the name of the
<A HREF="cmdline.html#history">history</A> file.  E.g.:

<B>	au BufReadPost * call ReadUndo()</B>
<B>	au BufWritePost * call WriteUndo()</B>
<B>	func ReadUndo()</B>
<B>	  if filereadable(expand('%:h'). '/UNDO/' . expand('%:t'))</B>
<B>	    rundo %:h/UNDO/%:t</B>
<B>	  endif</B>
<B>	endfunc</B>
<B>	func WriteUndo()</B>
<B>	  let dirname = expand('%:h') . '/UNDO'</B>
<B>	  if !isdirectory(dirname)</B>
<B>	    call mkdir(dirname)</B>
<B>	  endif</B>
<B>	  wundo %:h/UNDO/%:t</B>
<B>	endfunc</B>

You should keep <A HREF="options.html#'undofile'">'undofile'</A> off, otherwise you end up with two <A HREF="#undo">undo</A> files for
every write.

You can use the |<A HREF="eval.html#undofile()">undofile()</A>| function to find out the file name that Vim would
use.

Note that while reading/writing files and <A HREF="options.html#'undofile'">'undofile'</A> is set most <A HREF="message.html#errors">errors</A> will
be silent, unless <A HREF="options.html#'verbose'">'verbose'</A> is set.  With <A HREF="#:wundo">:wundo</A> and <A HREF="#:rundo">:rundo</A> you will get more
error <A HREF="message.html#messages">messages</A>, e.g., when the file cannot be read or written.

NOTE: <A HREF="#undo">undo</A> files are never deleted by Vim.  You need to delete them yourself.

Reading an existing <A HREF="#undo">undo</A> file may fail for several reasons:

*<A NAME="E822"></A><B>E822</B>*	It cannot be opened, because the file permissions don't allow <A HREF="motion.html#it">it</A>.

*<A NAME="E823"></A><B>E823</B>*	The magic number at the start of the file doesn't match.  This usually
	means <A HREF="motion.html#it">it</A> is not an <A HREF="#undo">undo</A> file.

*<A NAME="E824"></A><B>E824</B>*	The version number of the <A HREF="#undo">undo</A> file indicates that it's written by a
	newer version of Vim.  You need that newer version to open <A HREF="motion.html#it">it</A>.  Don't
	write the buffer if you want to keep the <A HREF="#undo">undo</A> info in the file.
&quot;File contents changed, cannot use <A HREF="#undo">undo</A> info&quot;
	The file text differs from when the <A HREF="#undo">undo</A> file was written.  This means
	the <A HREF="#undo">undo</A> file cannot be used, <A HREF="motion.html#it">it</A> would corrupt the text.  This also
	happens when <A HREF="options.html#'encoding'">'encoding'</A> differs from when the <A HREF="#undo">undo</A> file was written.

*<A NAME="E825"></A><B>E825</B>*  The <A HREF="#undo">undo</A> file does not contain valid contents and cannot be used.

*<A NAME="E826"></A><B>E826</B>*  The <A HREF="#undo">undo</A> file is encrypted but decryption failed.

*<A NAME="E827"></A><B>E827</B>*  The <A HREF="#undo">undo</A> file is encrypted but this version of Vim does not support
	<A HREF="editing.html#encryption">encryption</A>.  Open the file with another Vim.

*<A NAME="E832"></A><B>E832</B>*  The <A HREF="#undo">undo</A> file is encrypted but <A HREF="options.html#'key'">'key'</A> is not set, the text file is not
	encrypted.  This would happen if the text file was written by Vim
	encrypted at first, and later overwritten by not encrypted text.
	You probably want to delete this <A HREF="#undo">undo</A> file.
&quot;Not reading <A HREF="#undo">undo</A> file, owner differs&quot;
	The <A HREF="#undo">undo</A> file is owned by someone else than the owner of the text
	file.  For safety the <A HREF="#undo">undo</A> file is not used.

Writing an <A HREF="#undo">undo</A> file may fail for these reasons:

*<A NAME="E828"></A><B>E828</B>*	The file to be written cannot be created.  Perhaps you <A HREF="diff.html#do">do</A> not have
	write permissions in the directory.
&quot;Cannot write <A HREF="#undo">undo</A> file in any directory in 'undodir&#39;&#34;'
	None of the directories in <A HREF="options.html#'undodir'">'undodir'</A> can be used.
&quot;Will not overwrite with <A HREF="#undo">undo</A> file, cannot read&quot;
	A file exists with the name of the <A HREF="#undo">undo</A> file to be written, but <A HREF="motion.html#it">it</A>
	cannot be read.  You may want to delete this file or rename <A HREF="motion.html#it">it</A>.
&quot;Will not overwrite, this is not an <A HREF="#undo">undo</A> file&quot;
	A file exists with the name of the <A HREF="#undo">undo</A> file to be written, but <A HREF="motion.html#it">it</A>
	does not start with the right magic number.  You may want to delete
	this file or rename <A HREF="motion.html#it">it</A>.
&quot;Skipping <A HREF="#undo">undo</A> file write, nothing to undo&quot;
	There is no <A HREF="#undo">undo</A> information to be written, nothing has been changed
	or <A HREF="options.html#'undolevels'">'undolevels'</A> is negative.

*<A NAME="E829"></A><B>E829</B>*	An error occurred while <A HREF="editing.html#writing">writing</A> the <A HREF="#undo">undo</A> file.  You may want to try
	again.

==============================================================================

6. Remarks about <A HREF="#undo">undo</A>					*<A NAME="undo-remarks"></A><B>undo-remarks</B>*

The number of changes that are remembered is set with the <A HREF="options.html#'undolevels'">'undolevels'</A> option.
If <A HREF="motion.html#it">it</A> is zero, the Vi-compatible way is always used.  If <A HREF="motion.html#it">it</A> is negative no
<A HREF="#undo">undo</A> is possible.  Use this if you are running out of memory.


							*<A NAME="clear-undo"></A><B>clear-undo</B>*
When you set <A HREF="options.html#'undolevels'">'undolevels'</A> to -1 the <A HREF="#undo">undo</A> information is not immediately
cleared, this happens at the next change.  To force clearing the <A HREF="#undo">undo</A>
information you can use these commands:
<B>	:let old_undolevels = &amp;undolevels</B>
<B>	:set undolevels=-1</B>
<B>	:exe "normal a \&lt;BS&gt;\&lt;Esc&gt;"</B>
<B>	:let &amp;undolevels = old_undolevels</B>
<B>	:unlet old_undolevels</B>

Marks for the buffer ('a to 'z) are also saved and restored, together with the
text.  {Vi does this a little bit different}

When all changes have been undone, the buffer is not considered to be changed.
It is then possible to exit Vim with &quot;<A HREF="editing.html#:q">:q</A>&quot; instead of &quot;:q!&quot; {not in Vi}.  Note
that this is relative to the last write of the file.  Typing &quot;<A HREF="#u">u</A>&quot; after &quot;<A HREF="editing.html#:w">:w</A>&quot;
actually changes the buffer, compared to what was written, so the buffer is
considered changed then.

When manual |<A HREF="fold.html#folding">folding</A>| is being used, the <A HREF="fold.html#folds">folds</A> are not saved and restored.
Only changes completely within a fold will keep the fold <A HREF="motion.html#as">as</A> <A HREF="motion.html#it">it</A> was, because
the first and last line of the fold don't change.

The numbered <A HREF="change.html#registers">registers</A> can also be used for undoing deletes.  Each time you
delete text, <A HREF="motion.html#it">it</A> is put into <A HREF="sponsor.html#register">register</A> &quot;1.  The contents of <A HREF="sponsor.html#register">register</A> &quot;1 are
shifted to &quot;2, etc.  The contents of <A HREF="sponsor.html#register">register</A> &quot;9 are lost.  You can now get
back the most recent deleted text with the put command: &#39;&#34;'1P'.  (also, if the
deleted text was the result of the last delete or copy operation, '<A HREF="change.html#P">P</A>' or '<A HREF="change.html#p">p</A>'
also works <A HREF="motion.html#as">as</A> this puts the contents of the unnamed <A HREF="sponsor.html#register">register</A>).  You can get
back the text of three deletes ago with &#39;&#34;'3P'.


						*<A NAME="redo-register"></A><B>redo-register</B>*
If you want to get back more than one part of deleted text, you can use a
special feature of the repeat command &quot;<A HREF="repeat.html#.">.</A>&quot;.  It will increase the number of the
<A HREF="sponsor.html#register">register</A> used.  So if you first <A HREF="diff.html#do">do</A> &quot;&quot;1P&quot;, the following &quot;<A HREF="repeat.html#.">.</A>&quot; will result in a
&#39;&#34;'2P'.  Repeating this will result in all numbered <A HREF="change.html#registers">registers</A> being inserted.

Example:	If you deleted text with 'dd....' <A HREF="motion.html#it">it</A> can be restored with
		&#39;&#34;'1P....'.

If you don't know in which <A HREF="sponsor.html#register">register</A> the deleted text is, you can use the
<A HREF="change.html#:display">:display</A> command.  An alternative is to try the first <A HREF="sponsor.html#register">register</A> with &#39;&#34;'1P', and
if <A HREF="motion.html#it">it</A> is not what you want <A HREF="diff.html#do">do</A> 'u.'.  This will remove the contents of the
first put, and repeat the put command for the second <A HREF="sponsor.html#register">register</A>.  Repeat the
'u.' until you got what you want.

<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>


</HTML>