Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Undo command (the one with the with capital U)

Tags:

vim

vi

I don't understand how the undo line command works.

The documentation says Undo all latest changes on one line.

What is the definition of all latest changes here?

One behaviour I have noticed is that sometimes U undoes all writes after the very first write on a line. But this is not consistent. For example, when I open a new file and edit the first line, writing multiple times, the U command undoes every single change.

I haven't been able to find anything concrete from my google searches either.

like image 793
Lavya Avatar asked Nov 19 '14 12:11

Lavya


1 Answers

In my understanding all latest changes means going back the change history until a change in a different line is encountered, and stop there. So if you start with an empty buffer and edit only one line (repeatedly), all additions will be wiped by U.

Vim generally merges near changes occurring in the same line; these appear as a single entry in :changes.

like image 73
Ingo Karkat Avatar answered Sep 23 '22 11:09

Ingo Karkat