annotate runtime/doc/usr_32.txt @ 10501:cd36f3024b06 v8.0.0143

commit https://github.com/vim/vim/commit/f845b87f2b3a45cbee160e28d7a3f50e54054809 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 6 14:04:54 2017 +0100 patch 8.0.0143: line number of current buffer in getbufinfo() is wrong Problem: Line number of current buffer in getbufinfo() is wrong. Solution: For the current buffer use the current line number. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Fri, 06 Jan 2017 14:15:04 +0100
parents 9f48eab77d62
children 1174611ad715
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10198
9f48eab77d62 commit https://github.com/vim/vim/commit/bb76f24af2010943387ce696a7092175b4ecccf2
Christian Brabandt <cb@256bit.org>
parents: 5294
diff changeset
1 *usr_32.txt* For Vim version 8.0. Last change: 2010 Jul 20
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
2
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
3 VIM USER MANUAL - by Bram Moolenaar
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
4
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
5 The undo tree
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
6
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
7
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
8 Vim provides multi-level undo. If you undo a few changes and then make a new
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
9 change you create a branch in the undo tree. This text is about moving
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
10 through the branches.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
11
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
12 |32.1| Undo up to a file write
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
13 |32.2| Numbering changes
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
14 |32.3| Jumping around the tree
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
15 |32.4| Time travelling
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
16
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
17 Next chapter: |usr_40.txt| Make new commands
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
18 Previous chapter: |usr_31.txt| Exploiting the GUI
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
19 Table of contents: |usr_toc.txt|
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
20
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
21 ==============================================================================
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
22 *32.1* Undo up to a file write
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
23
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
24 Sometimes you make several changes, and then discover you want to go back to
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
25 when you have last written the file. You can do that with this command: >
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
26
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
27 :earlier 1f
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
28
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
29 The "f" stands for "file" here.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
30
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
31 You can repeat this command to go further back in the past. Or use a count
2355
84c7eeeb09e2 Fix typos in documentation. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2345
diff changeset
32 different from 1 to go back faster.
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
33
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
34 If you go back too far, go forward again with: >
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
35
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
36 :later 1f
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
37
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
38 Note that these commands really work in time sequence. This matters if you
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
39 made changes after undoing some changes. It's explained in the next section.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
40
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
41 Also note that we are talking about text writes here. For writing the undo
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
42 information in a file see |undo-persistence|.
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
43
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
44 ==============================================================================
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
45 *32.2* Numbering changes
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
46
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
47 In section |02.5| we only discussed one line of undo/redo. But it is also
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
48 possible to branch off. This happens when you undo a few changes and then
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
49 make a new change. The new changes become a branch in the undo tree.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
50
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
51 Let's start with the text "one". The first change to make is to append
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
52 " too". And then move to the first 'o' and change it into 'w'. We then have
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
53 two changes, numbered 1 and 2, and three states of the text:
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
54
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
55 one ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
56 |
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
57 change 1
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
58 |
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
59 one too ~
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
60 |
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
61 change 2
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
62 |
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
63 one two ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
64
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
65 If we now undo one change, back to "one too", and change "one" to "me" we
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
66 create a branch in the undo tree:
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
67
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
68 one ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
69 |
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
70 change 1
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
71 |
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
72 one too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
73 / \
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
74 change 2 change 3
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
75 | |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
76 one two me too ~
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
77
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
78 You can now use the |u| command to undo. If you do this twice you get to
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
79 "one". Use |CTRL-R| to redo, and you will go to "one too". One more |CTRL-R|
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
80 takes you to "me too". Thus undo and redo go up and down in the tree, using
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
81 the branch that was last used.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
82
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
83 What matters here is the order in which the changes are made. Undo and redo
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
84 are not considered changes in this context. After each change you have a new
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
85 state of the text.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
86
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
87 Note that only the changes are numbered, the text shown in the tree above has
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
88 no identifier. They are mostly referred to by the number of the change above
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
89 it. But sometimes by the number of one of the changes below it, especially
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
90 when moving up in the tree, so that you know which change was just undone.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
91
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
92 ==============================================================================
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
93 *32.3* Jumping around the tree
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
94
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
95 So how do you get to "one two" now? You can use this command: >
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
96
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
97 :undo 2
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
98
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
99 The text is now "one two", you are below change 2. You can use the |:undo|
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
100 command to jump to below any change in the tree.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
101
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
102 Now make another change: change "one" to "not":
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
103
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
104 one ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
105 |
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
106 change 1
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
107 |
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
108 one too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
109 / \
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
110 change 2 change 3
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
111 | |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
112 one two me too ~
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
113 |
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
114 change 4
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
115 |
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
116 not two ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
117
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
118 Now you change your mind and want to go back to "me too". Use the |g-|
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
119 command. This moves back in time. Thus it doesn't walk the tree upwards or
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
120 downwards, but goes to the change made before.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
121
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
122 You can repeat |g-| and you will see the text change:
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
123 me too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
124 one two ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
125 one too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
126 one ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
127
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
128 Use |g+| to move forward in time:
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
129 one ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
130 one too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
131 one two ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
132 me too ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
133 not two ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
134
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
135 Using |:undo| is useful if you know what change you want to jump to. |g-| and
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
136 |g+| are useful if you don't know exactly what the change number is.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
137
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
138 You can type a count before |g-| and |g+| to repeat them.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
139
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
140 ==============================================================================
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
141 *32.4* Time travelling
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
142
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
143 When you have been working on text for a while the tree grows to become big.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
144 Then you may want to go to the text of some minutes ago.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
145
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
146 To see what branches there are in the undo tree use this command: >
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
147
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
148 :undolist
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
149 < number changes time ~
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
150 3 2 16 seconds ago
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
151 4 3 5 seconds ago
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
152
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
153 Here you can see the number of the leaves in each branch and when the change
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
154 was made. Assuming we are below change 4, at "not two", you can go back ten
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
155 seconds with this command: >
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
156
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
157 :earlier 10s
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
158
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
159 Depending on how much time you took for the changes you end up at a certain
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
160 position in the tree. The |:earlier| command argument can be "m" for minutes,
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
161 "h" for hours and "d" for days. To go all the way back use a big number: >
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
162
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
163 :earlier 100d
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
164
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
165 To travel forward in time again use the |:later| command: >
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
166
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
167 :later 1m
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
168
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
169 The arguments are "s", "m" and "h", just like with |:earlier|.
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
170
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
171 If you want even more details, or want to manipulate the information, you can
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
172 use the |undotree()| function. To see what it returns: >
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
173
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
174 :echo undotree()
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
175
799
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
176 ==============================================================================
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
177
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
178 Next chapter: |usr_40.txt| Make new commands
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
179
6beb2c667935 updated for version 7.0b
vimboss
parents:
diff changeset
180 Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: