Monday, November 30, 2009

Text States

If you're using Vim 7+, you can use g- and g+ to go between text states. For a more advanced usage see the :help earlier and :help later.


Unknown said...

Actually, if you have any hints on how to use the undo tree effectively (as more than just u and :red) that would be wonderful

Anonymous said...

I usually use, from normal mode; "u" and "ctrl-r" for {un,re}do respectively.

Anonymous said...

Agree with anon... How is this any better than just using u and control-R? When would I use this?

Anonymous said...

Using g+ and g- is very different than using u and ^r.
Try following:
* Create new file
* (in normal mode) Type iOne - Esc
* Type oTwo - Esc
* Type oThree - Esc
* Type oFour - Esc
* Type oFive - Esc
* Type 2u
* Type oSix - Esc
* Type oSeven - Esc

Now you have an undo tree with 2 branches. Typing u only goes up the last branch. Using g- goes up by time - branch doesn't matter here.

Have a look in :help usr_32.txt for good explanation of using the undo tree.