May 2018
Intermediate to advanced
168 pages
4h 2m
English
| Tip 24 | Making 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 ...