/usr/share/doc/vim-doc/html/usr_32.html is in vim-doc 2:7.4.488-7+deb8u3.
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 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: usr_32</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: usr_32</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="usr_32.txt"></A><B>usr_32.txt</B>* For Vim version 7.4. Last change: 2010 Jul 20
VIM USER MANUAL - by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
The <A HREF="undo.html#undo">undo</A> tree
Vim provides multi-level <A HREF="undo.html#undo">undo</A>. If you <A HREF="undo.html#undo">undo</A> a few changes and then make a new
change you create a branch in the <A HREF="undo.html#undo">undo</A> tree. This text is about moving
through the branches.
|<A HREF="#32.1">32.1</A>| Undo up to a file write
|<A HREF="#32.2">32.2</A>| Numbering changes
|<A HREF="#32.3">32.3</A>| Jumping around the tree
|<A HREF="#32.4">32.4</A>| Time travelling
Next chapter: |<A HREF="usr_40.html">usr_40.txt</A>| Make new commands
Previous chapter: |<A HREF="usr_31.html">usr_31.txt</A>| Exploiting the <A HREF="gui.html#GUI">GUI</A>
Table of contents: |<A HREF="usr_toc.html">usr_toc.txt</A>|
==============================================================================
*<A NAME="32.1"></A><B>32.1</B>* Undo up to a file write
Sometimes you make several changes, and then discover you want to go back to
when you have last written the file. You can <A HREF="diff.html#do">do</A> that with this command:
<B> :earlier 1f</B>
The "<A HREF="motion.html#f">f</A>" stands for "file" here.
You can repeat this command to go further back in the past. Or use a <A HREF="intro.html#count">count</A>
different from 1 to go back faster.
If you go back too far, go forward again with:
<B> :later 1f</B>
Note that these commands really work in time sequence. This matters if you
made changes after undoing some changes. It's explained in the next section.
Also note that we are talking about text writes here. For <A HREF="editing.html#writing">writing</A> the <A HREF="undo.html#undo">undo</A>
information in a file see |<A HREF="undo.html#undo-persistence">undo-persistence</A>|.
==============================================================================
*<A NAME="32.2"></A><B>32.2</B>* Numbering changes
In section |<A HREF="usr_02.html#02.5">02.5</A>| 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.html#undo">undo</A> a few changes and then
make a new change. The new changes become a branch in the <A HREF="undo.html#undo">undo</A> tree.
Let's start with the text "one". The first change to make is to append
" too". And then move to the first '<A HREF="insert.html#o">o</A>' and change <A HREF="motion.html#it">it</A> into '<A HREF="motion.html#w">w</A>'. We then have
two changes, numbered 1 and 2, and three states of the text:
<B><FONT COLOR="PURPLE"> one </FONT></B>
|
change 1
|
<B><FONT COLOR="PURPLE"> one too </FONT></B>
|
change 2
|
<B><FONT COLOR="PURPLE"> one two </FONT></B>
If we now <A HREF="undo.html#undo">undo</A> one change, back to "one too", and change "one" to "me" we
create a branch in the <A HREF="undo.html#undo">undo</A> tree:
<B><FONT COLOR="PURPLE"> one </FONT></B>
|
change 1
|
<B><FONT COLOR="PURPLE"> one too </FONT></B>
/ \
change 2 change 3
| |
<B><FONT COLOR="PURPLE"> one two me too </FONT></B>
You can now use the |<A HREF="undo.html#u">u</A>| command to <A HREF="undo.html#undo">undo</A>. If you <A HREF="diff.html#do">do</A> this <A HREF="if_cscop.html#twice">twice</A> you get to
"one". Use |<A HREF="undo.html#CTRL-R">CTRL-R</A>| to <A HREF="undo.html#redo">redo</A>, and you will go to "one too". One more |<A HREF="undo.html#CTRL-R">CTRL-R</A>|
takes you to "me too". Thus <A HREF="undo.html#undo">undo</A> and <A HREF="undo.html#redo">redo</A> go up and down in the tree, using
the branch that was last used.
What matters here is the order in which the changes are made. Undo and <A HREF="undo.html#redo">redo</A>
are not considered changes in this context. After each change you have a new
state of the text.
Note that only the changes are numbered, the text shown in the tree above has
no identifier. They are mostly referred to by the number of the change above
<A HREF="motion.html#it">it</A>. But sometimes by the number of one of the changes below <A HREF="motion.html#it">it</A>, especially
when moving up in the tree, so that you know which change was just undone.
==============================================================================
*<A NAME="32.3"></A><B>32.3</B>* Jumping around the tree
So how <A HREF="diff.html#do">do</A> you get to "one two" now? You can use this command:
<B> :undo 2</B>
The text is now "one two", you are below change 2. You can use the |<A HREF="undo.html#:undo">:undo</A>|
command to jump to below any change in the tree.
Now make another change: change "one" to "not":
<B><FONT COLOR="PURPLE"> one </FONT></B>
|
change 1
|
<B><FONT COLOR="PURPLE"> one too </FONT></B>
/ \
change 2 change 3
| |
<B><FONT COLOR="PURPLE"> one two me too </FONT></B>
|
change 4
|
<B><FONT COLOR="PURPLE"> not two </FONT></B>
Now you change your mind and want to go back to "me too". Use the |<A HREF="undo.html#g-">g-</A>|
command. This moves back in time. Thus <A HREF="motion.html#it">it</A> doesn't walk the tree upwards or
downwards, but goes to the change made before.
You can repeat |<A HREF="undo.html#g-">g-</A>| and you will see the text change:
<B><FONT COLOR="PURPLE"> me too </FONT></B>
<B><FONT COLOR="PURPLE"> one two </FONT></B>
<B><FONT COLOR="PURPLE"> one too </FONT></B>
<B><FONT COLOR="PURPLE"> one </FONT></B>
Use |<A HREF="undo.html#g+">g+</A>| to move forward in time:
<B><FONT COLOR="PURPLE"> one </FONT></B>
<B><FONT COLOR="PURPLE"> one too </FONT></B>
<B><FONT COLOR="PURPLE"> one two </FONT></B>
<B><FONT COLOR="PURPLE"> me too </FONT></B>
<B><FONT COLOR="PURPLE"> not two </FONT></B>
Using |<A HREF="undo.html#:undo">:undo</A>| is useful if you know what change you want to jump to. |<A HREF="undo.html#g-">g-</A>| and
|<A HREF="undo.html#g+">g+</A>| are useful if you don't know exactly what the change number is.
You can type a <A HREF="intro.html#count">count</A> before |<A HREF="undo.html#g-">g-</A>| and |<A HREF="undo.html#g+">g+</A>| to repeat them.
==============================================================================
*<A NAME="32.4"></A><B>32.4</B>* Time travelling
When you have been working on text for a while the tree grows to become big.
Then you may want to go to the text of some minutes ago.
To see what branches there are in the <A HREF="undo.html#undo">undo</A> tree use this command:
<B> :undolist</B>
<B><FONT COLOR="PURPLE"> number changes time </FONT></B>
3 2 16 seconds ago
4 3 5 seconds ago
Here you can see the number of the leaves in each branch and when the change
was made. Assuming we are below change 4, at "not two", you can go back ten
seconds with this command:
<B> :earlier 10s</B>
Depending on how much time you took for the changes you end up at a certain
position in the tree. The |<A HREF="undo.html#:earlier">:earlier</A>| command argument can be "<A HREF="motion.html#m">m</A>" for minutes,
"<A HREF="motion.html#h">h</A>" for hours and "<A HREF="change.html#d">d</A>" for days. To go all the way back use a big number:
<B> :earlier 100d</B>
To travel forward in time again use the |<A HREF="undo.html#:later">:later</A>| command:
<B> :later 1m</B>
The arguments are "<A HREF="change.html#s">s</A>", "<A HREF="motion.html#m">m</A>" and "<A HREF="motion.html#h">h</A>", just like with |<A HREF="undo.html#:earlier">:earlier</A>|.
If you want even more details, or want to manipulate the information, you can
use the |<A HREF="eval.html#undotree()">undotree()</A>| function. To see what <A HREF="motion.html#it">it</A> returns:
<B> :echo undotree()</B>
==============================================================================
Next chapter: |<A HREF="usr_40.html">usr_40.txt</A>| Make new commands
Copyright: see |<A HREF="usr_01.html#manual-copyright">manual-copyright</A>| vim:tw=78:ts=8:ft=help:norl:
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|