annotate runtime/doc/undo.txt @ 16553:0e473e9e70c2 v8.1.1280

patch 8.1.1280: remarks about functionality not in Vi clutters the help commit https://github.com/vim/vim/commit/25c9c680ec4dfbb51f4ef21c3460a48d3c67ffc8 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 5 18:13:34 2019 +0200 patch 8.1.1280: remarks about functionality not in Vi clutters the help Problem: Remarks about functionality not in Vi clutters the help. Solution: Move all info about what is new in Vim or already existed in Vi to vi_diff.txt. Remove {not in Vi} remarks. (closes #4268) Add "noet" to the help files modeline. Also include many other help file improvements.
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 May 2019 18:15:06 +0200
parents f0f06837a699
children 1eaf34420bb3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
1 *undo.txt* For Vim version 8.1. Last change: 2019 May 05
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 VIM REFERENCE MANUAL by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 Undo and redo *undo-redo*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 The basics are explained in section |02.5| of the user manual.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 1. Undo and redo commands |undo-commands|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 2. Two ways of undo |undo-two-ways|
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
13 3. Undo blocks |undo-blocks|
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 1. Undo and redo commands *undo-commands*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 <Undo> or *undo* *<Undo>* *u*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 u Undo [count] changes. {Vi: only one level}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 *:u* *:un* *:undo*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
27 :u[ndo] {N} Jump to after change number {N}. See |undo-branches|
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
28 for the meaning of {N}.
772
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
29
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 *CTRL-R*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 CTRL-R Redo [count] changes which were undone. {Vi: redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 screen}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 *:red* *:redo* *redo*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 :red[o] Redo one change which was undone. {Vi: no redo}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 *U*
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
38 U Undo all latest changes on one line, the line where
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
39 the latest change was made. |U| itself also counts as
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
40 a change, and thus |U| undoes a previous |U|.
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
41 {Vi: while not moved off of the last modified line}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 The last changes are remembered. You can use the undo and redo commands above
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 to revert the text to how it was before each change. You can also apply the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 changes again, getting back the text before the undo.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 The "U" command is treated by undo/redo just like any other command. Thus a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 "u" command undoes a "U" command and a 'CTRL-R' command redoes it again. When
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 restore the situation of a line to before the previous "U" command. This may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 be confusing. Try it out to get used to it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 The "U" command will always mark the buffer as changed. When "U" changes the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 buffer back to how it was without changes, it is still considered changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 Use "u" to undo changes until the buffer becomes unchanged.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 2. Two ways of undo *undo-two-ways*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 How undo and redo commands work depends on the 'u' flag in 'cpoptions'.
5340
22da5ab9aaa1 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5294
diff changeset
60 There is the Vim way ('u' excluded) and the Vi-compatible way ('u' included).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 In the Vim way, "uu" undoes two changes. In the Vi-compatible way, "uu" does
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 nothing (undoes an undo).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 'u' excluded, the Vim way:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 You can go back in time with the undo command. You can then go forward again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 with the redo command. If you make a new change after the undo command,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 the redo will not be possible anymore.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 'u' included, the Vi-compatible way:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 The undo command undoes the previous change, and also the previous undo command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 The redo command repeats the previous undo command. It does NOT repeat a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 change command, use "." for that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 Examples Vim way Vi-compatible way ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 "uu" two times undo no-op
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 "u CTRL-R" no-op two times undo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 Rationale: Nvi uses the "." command instead of CTRL-R. Unfortunately, this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 is not Vi compatible. For example "dwdwu." in Vi deletes two
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 words, in Nvi it does nothing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 ==============================================================================
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
83 3. Undo blocks *undo-blocks*
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
84
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
85 One undo command normally undoes a typed command, no matter how many changes
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
86 that command makes. This sequence of undo-able changes forms an undo block.
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
87 Thus if the typed key(s) call a function, all the commands in the function are
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
88 undone together.
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
89
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
90 If you want to write a function or script that doesn't create a new undoable
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
91 change but joins in with the previous change use this command:
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
92
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 834
diff changeset
93 *:undoj* *:undojoin* *E790*
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
94 :undoj[oin] Join further changes with the previous undo block.
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
95 Warning: Use with care, it may prevent the user from
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 834
diff changeset
96 properly undoing changes. Don't use this after undo
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 834
diff changeset
97 or redo.
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
98
5968
92751673cc37 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
99 This is most useful when you need to prompt the user halfway through a change.
92751673cc37 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
100 For example in a function that calls |getchar()|. Do make sure that there was
92751673cc37 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5362
diff changeset
101 a related change before this that you must join with.
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
102
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
103 This doesn't work by itself, because the next key press will start a new
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
104 change again. But you can do something like this: >
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
105
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
106 :undojoin | delete
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
107
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
108 After this an "u" command will undo the delete command and the previous
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
109 change.
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
110
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
111 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
112 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
113 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
114 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
115 is equal to the old value.
2033
de5a43c5eedc Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
116
697
f08390485cd3 updated for version 7.0210
vimboss
parents: 7
diff changeset
117 ==============================================================================
827
fd1b3406fd1c updated for version 7.0d02
vimboss
parents: 825
diff changeset
118 4. Undo branches *undo-branches* *undo-tree*
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
119
793
8c0b00d50acf updated for version 7.0231
vimboss
parents: 772
diff changeset
120 Above we only discussed one line of undo/redo. But it is also possible to
8c0b00d50acf updated for version 7.0231
vimboss
parents: 772
diff changeset
121 branch off. This happens when you undo a few changes and then make a new
8c0b00d50acf updated for version 7.0231
vimboss
parents: 772
diff changeset
122 change. The undone changes become a branch. You can go to that branch with
8c0b00d50acf updated for version 7.0231
vimboss
parents: 772
diff changeset
123 the following commands.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
124
799
6beb2c667935 updated for version 7.0b
vimboss
parents: 793
diff changeset
125 This is explained in the user manual: |usr_32.txt|.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
126
772
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
127 *:undol* *:undolist*
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
128 :undol[ist] List the leafs in the tree of changes. Example:
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
129 number changes when saved ~
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
130 88 88 2010/01/04 14:25:53
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
131 108 107 08/07 12:47:51
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
132 136 46 13:33:01 7
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
133 166 164 3 seconds ago
772
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
134
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
135 The "number" column is the change number. This number
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
136 continuously increases and can be used to identify a
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
137 specific undo-able change, see |:undo|.
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
138 The "changes" column is the number of changes to this
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
139 leaf from the root of the tree.
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
140 The "when" column is the date and time when this
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
141 change was made. The four possible formats are:
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
142 N seconds ago
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
143 HH:MM:SS hour, minute, seconds
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
144 MM/DD HH:MM:SS idem, with month and day
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2625
diff changeset
145 YYYY/MM/DD HH:MM:SS idem, with year
2581
e8a482a7fa6c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
146 The "saved" column specifies, if this change was
e8a482a7fa6c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
147 written to disk and which file write it was. This can
2596
fae782ef63dd Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2581
diff changeset
148 be used with the |:later| and |:earlier| commands.
2280
941ff1cd317a Add file save counter to undo information. Add undotree() function.
Bram Moolenaar <bram@vim.org>
parents: 2251
diff changeset
149 For more details use the |undotree()| function.
772
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
150
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
151 *g-*
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
152 g- Go to older text state. With a count repeat that many
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
153 times.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
154 *:ea* *:earlier*
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
155 :earlier {count} Go to older text state {count} times.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
156 :earlier {N}s Go to older text state about {N} seconds before.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
157 :earlier {N}m Go to older text state about {N} minutes before.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
158 :earlier {N}h Go to older text state about {N} hours before.
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
159 :earlier {N}d Go to older text state about {N} days before.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
160
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
161 :earlier {N}f Go to older text state {N} file writes before.
2581
e8a482a7fa6c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
162 When changes were made since the last write
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
163 ":earlier 1f" will revert the text to the state when
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
164 it was written. Otherwise it will go to the write
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
165 before that.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
166 When at the state of the first file write, or when
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
167 the file was not written, ":earlier 1f" will go to
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
168 before the first change.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
169
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
170 *g+*
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
171 g+ Go to newer text state. With a count repeat that many
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
172 times.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
173 *:lat* *:later*
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
174 :later {count} Go to newer text state {count} times.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
175 :later {N}s Go to newer text state about {N} seconds later.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
176 :later {N}m Go to newer text state about {N} minutes later.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
177 :later {N}h Go to newer text state about {N} hours later.
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
178 :later {N}d Go to newer text state about {N} days later.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
179
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
180 :later {N}f Go to newer text state {N} file writes later.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
181 When at the state of the last file write, ":later 1f"
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2280
diff changeset
182 will go to the newest text state.
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
183
772
aaaca5077255 updated for version 7.0226
vimboss
parents: 758
diff changeset
184
758
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
185 Note that text states will become unreachable when undo information is cleared
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
186 for 'undolevels'.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
187
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
188 Don't be surprised when moving through time shows multiple changes to take
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
189 place at a time. This happens when moving through the undo tree and then
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
190 making a new change.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
191
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
192 EXAMPLE
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
193
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
194 Start with this text:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
195 one two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
196
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
197 Delete the first word by pressing "x" three times:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
198 ne two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
199 e two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
200 two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
201
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
202 Now undo that by pressing "u" three times:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
203 e two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
204 ne two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
205 one two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
206
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
207 Delete the second word by pressing "x" three times:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
208 one wo three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
209 one o three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
210 one three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
211
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
212 Now undo that by using "g-" three times:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
213 one o three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
214 one wo three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
215 two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
216
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
217 You are now back in the first undo branch, after deleting "one". Repeating
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
218 "g-" will now bring you back to the original text:
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
219 e two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
220 ne two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
221 one two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
222
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
223 Jump to the last change with ":later 1h":
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
224 one three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
225
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
226 And back to the start again with ":earlier 1h":
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
227 one two three ~
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
228
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
229
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
230 Note that using "u" and CTRL-R will not get you to all possible text states
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
231 while repeating "g-" and "g+" does.
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
232
d591d4ceeaee updated for version 7.0224
vimboss
parents: 697
diff changeset
233 ==============================================================================
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
234 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
235
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
236 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
237 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
238 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
239 the file again.
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
240
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
241 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
242 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
243 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
244 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
245
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
246 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
247 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
248 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
249 for (with a hash of the file contents) and ignore it when the file was changed
2625
0aa21d63aba0 Updated runtile files.
Bram Moolenaar <bram@vim.org>
parents: 2596
diff changeset
250 after the undo file was written, to prevent corruption. An undo file is also
5362
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents: 5340
diff changeset
251 ignored if its owner differs from the owner of the edited file, except when
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents: 5340
diff changeset
252 the owner of the undo file is the current user. Set 'verbose' to get a
ab1508486b12 Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents: 5340
diff changeset
253 message about that when opening a file.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
254
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
255 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
256 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
257
2239
732cb7b31956 Crypt the text in the undo file if the file itself is crypted.
Bram Moolenaar <bram@vim.org>
parents: 2238
diff changeset
258 When the file is encrypted, the text in the undo file is also crypted. The
732cb7b31956 Crypt the text in the undo file if the file itself is crypted.
Bram Moolenaar <bram@vim.org>
parents: 2238
diff changeset
259 same key and method is used. |encryption|
732cb7b31956 Crypt the text in the undo file if the file itself is crypted.
Bram Moolenaar <bram@vim.org>
parents: 2238
diff changeset
260
15512
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
261 Note that text properties are not stored in the undo file. You can restore
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
262 text properties so long as a buffer is loaded, but you cannot restore them
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
263 from an undo file. Rationale: It would require the associated text property
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
264 types to be defined in exactly the same was as before, which cannot be
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
265 guaranteed.
f0f06837a699 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14519
diff changeset
266
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
267 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
268 respectively:
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
269 *:wundo* *:rundo*
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
270 :wundo[!] {file}
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
271 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
272 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
273 (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
274 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
275 If it exists and does look like an undo file it is
3312
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
276 overwritten. If there is no undo-history, nothing will be
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
277 written.
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
278 Implementation detail: Overwriting happens by first deleting
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
279 the existing file and then creating a new file with the same
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
280 name. So it is not possible to overwrite an existing undofile
b7811ab264bf updated for version 7.3.423
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
281 in a write-protected directory.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
282
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
283 :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
284
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
285 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
286 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
287
2236
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
288 au BufReadPost * call ReadUndo()
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
289 au BufWritePost * call WriteUndo()
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
290 func ReadUndo()
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
291 if filereadable(expand('%:h'). '/UNDO/' . expand('%:t'))
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
292 rundo %:h/UNDO/%:t
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
293 endif
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
294 endfunc
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
295 func WriteUndo()
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
296 let dirname = expand('%:h') . '/UNDO'
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
297 if !isdirectory(dirname)
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
298 call mkdir(dirname)
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
299 endif
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
300 wundo %:h/UNDO/%:t
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
301 endfunc
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
302
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
303 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
304 every write.
2236
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
305
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
306 You can use the |undofile()| function to find out the file name that Vim would
dc2e5ec0500d Added the undofile() function. Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2231
diff changeset
307 use.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
308
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
309 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
310 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
311 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
312
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
313 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
314
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
315 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
316 *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
317 *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
318 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
319 *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
320 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
321 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
322 "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
323 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
324 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
325 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
326 *E825* The undo file does not contain valid contents and cannot be used.
2251
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
327 *E826* The undo file is encrypted but decryption failed.
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
328 *E827* The undo file is encrypted but this version of Vim does not support
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
329 encryption. Open the file with another Vim.
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
330 *E832* The undo file is encrypted but 'key' is not set, the text file is not
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
331 encrypted. This would happen if the text file was written by Vim
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
332 encrypted at first, and later overwritten by not encrypted text.
646d34788036 Fix a few compiler warnings. Fix crash with encrypted undo file.
Bram Moolenaar <bram@vim.org>
parents: 2249
diff changeset
333 You probably want to delete this undo file.
2238
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
334 "Not reading undo file, owner differs"
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
335 The undo file is owned by someone else than the owner of the text
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
336 file. For safety the undo file is not used.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
337
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
338 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
339 *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
340 write permissions in the directory.
2238
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
341 "Cannot write undo file in any directory in 'undodir'"
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
342 None of the directories in 'undodir' can be used.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
343 "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
344 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
345 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
346 "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
347 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
348 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
349 this file or rename it.
2581
e8a482a7fa6c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
350 "Skipping undo file write, nothing to undo"
e8a482a7fa6c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
351 There is no undo information to be written, nothing has been changed
2238
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2236
diff changeset
352 or 'undolevels' is negative.
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
353 *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
354 again.
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
355
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
356 ==============================================================================
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
357 6. Remarks about undo *undo-remarks*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 The number of changes that are remembered is set with the 'undolevels' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 If it is zero, the Vi-compatible way is always used. If it is negative no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 undo is possible. Use this if you are running out of memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
2249
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
363 *clear-undo*
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
364 When you set 'undolevels' to -1 the undo information is not immediately
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
365 cleared, this happens at the next change. To force clearing the undo
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
366 information you can use these commands: >
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
367 :let old_undolevels = &undolevels
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
368 :set undolevels=-1
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
369 :exe "normal a \<BS>\<Esc>"
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
370 :let &undolevels = old_undolevels
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
371 :unlet old_undolevels
6d3d35ff2c2b Use full path in undofile(). Updated docs.
Bram Moolenaar <bram@vim.org>
parents: 2239
diff changeset
372
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 Marks for the buffer ('a to 'z) are also saved and restored, together with the
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
374 text.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 When all changes have been undone, the buffer is not considered to be changed.
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15512
diff changeset
377 It is then possible to exit Vim with ":q" instead of ":q!". Note
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 that this is relative to the last write of the file. Typing "u" after ":w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 actually changes the buffer, compared to what was written, so the buffer is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 considered changed then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 When manual |folding| is being used, the folds are not saved and restored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 Only changes completely within a fold will keep the fold as it was, because
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 the first and last line of the fold don't change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 The numbered registers can also be used for undoing deletes. Each time you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 delete text, it is put into register "1. The contents of register "1 are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 shifted to "2, etc. The contents of register "9 are lost. You can now get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 back the most recent deleted text with the put command: '"1P'. (also, if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 deleted text was the result of the last delete or copy operation, 'P' or 'p'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 also works as this puts the contents of the unnamed register). You can get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 back the text of three deletes ago with '"3P'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 *redo-register*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 If you want to get back more than one part of deleted text, you can use a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 special feature of the repeat command ".". It will increase the number of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 register used. So if you first do ""1P", the following "." will result in a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 '"2P'. Repeating this will result in all numbered registers being inserted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 Example: If you deleted text with 'dd....' it can be restored with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 '"1P....'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 If you don't know in which register the deleted text is, you can use the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 :display command. An alternative is to try the first register with '"1P', and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if it is not what you want do 'u.'. This will remove the contents of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 first put, and repeat the put command for the second register. Repeat the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 'u.' until you got what you want.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
14519
5c5908e81e93 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
409 vim:tw=78:ts=8:noet:ft=help:norl: