Skip to Content
Modern Vim
book

Modern Vim

by Drew Neil
May 2018
Intermediate to advanced
168 pages
4h 2m
English
Pragmatic Bookshelf
Content preview from Modern Vim
Tip 24Making Undo Persist Between Sessions

The undo command is a lifesaver when you need to revert changes that didn’t work out. Typically, you can only undo changes that were made to a file during the current editing session. By enabling Vim’s ‘undofile’ option, you can make undo history persist between editing sessions.

Open the green-bottles.txt file from the source code that accompanies this book in Vim:

 10 green bottles hanging on the wall.

Use the <C-x> command to decrement the number at the start of the line. Now you can use u to undo the change and <C-r> to redo it. If you quit Vim and then reopen the same file, what do you expect to happen when you use the u command?

Your undo history is usually lost when you ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9781680506006Errata Page