On one of my dev machines I have unlimited undos, I can hold u and go all the way back to when I opened the file.
On another, pressing u toggles between the last two changes I made, no more.
The first dev machine I have Administrator access to and the vim installer had free reign. The second I do not and vim had to be installed off the normal OS paths and have to launch vim with a 'Sendto'. Perhaps this is related and I'm missing some rc commands. Also noticed I have to run 'syn on' to get highlighting on that box. vimrc was also blank so now I'm sure it has something to do with it.
From other threads I don't believe this is related to the persistent undo feature, but simply a .swp or ~ issue (whatever those files are used for..)
Deadlines have prompted punting what is probably a simple issue.. How do I fix this?
After reading this article, you should understand how to use the undo and redo commands in Vim / Vi. Remember, yo undo a change in Vim / Vi use the command u, and to redo a change which was undone use Ctrl-R. Once you have finished, make sure to save the Vim file before exiting.
U is seldom useful in practice, but is often accidentally pressed instead of u, so it is good to know about. Note that unlike most programs which maintain a linear undo history, Vim maintains an undo tree containing every edit made to a buffer. To learn how to use Vim's undo tree, see the separate article on using undo branches .
Knowing Vim’s basics might be very useful when you encounter a situation where your favorite editor is not available. Vim keeps track of all the changes you made in the current session. The undo command undoes one or more changes in the order in which they were made.
In Vim, every time you press u and then make a different change, Vim stores the previous state's text by creating an "undo branch". In this example, after you typed "two", then pressed u, then typed "three", you created an leaf branch that stores the state containing the text "two".
vimrc was blank on the affected box.
I added these lines from my other dev box and everything was hapy again.
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
Looks like you need a vimrc file on the second box: see :he compatible-default
.
If there is no vimrc file, vim runs in vi compatible mode, and there is no syntax highlighting etc...
Create one. Output of :version
will show you more where the files are expected.
If undo still does not work have a look at :he undo-two-ways
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With