Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim undo limited to one step on some hosts

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?

like image 302
Daren Schwenke Avatar asked Feb 01 '12 06:02

Daren Schwenke


People also ask

How to use undo and redo commands in vim/vi?

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.

What is the use of UU in Vim?

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 .

What is Vim and how to use it?

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.

How does Vim store the previous state of text?

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".


2 Answers

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
like image 78
Daren Schwenke Avatar answered Oct 15 '22 14:10

Daren Schwenke


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.

like image 29
Martian Avatar answered Oct 15 '22 15:10

Martian