Course Lessons
Free Trial: 5 lessons remaining
Unlock Full Access
Navigating the Undo Tree
Estimated time: 10 minutes
Task Instructions
Explore Vim's undo tree and learn to navigate between branches
Make different changes to create undo branches, then use g- to travel back in time and g+ to travel forward. This demonstrates how Vim never loses your work.
Learning objectives
- Master g- and g+ for undo tree navigation
- Understand how Vim's undo tree preserves all changes
- Learn to navigate between different change branches
Required Keystrokes
This lesson requires you to use specific keystrokes to complete it. Your submission will be evaluated based on whether you used the required keystrokes mentioned below, rather than matching a specific output.
u
Use undo
g-
Navigate back in undo tree
g\+
Navigate forward in undo tree
What This Means
- Your solution must include the required keystroke patterns
- The order of keystrokes may matter depending on the exercise
- You'll still need to achieve the expected output
- This helps you practice specific Vim techniques
Helpful commands:
| Command | Description |
|---|---|
| u | Undo |
| Ctrl-r | Redo |
| g- | Go back in time |
| g+ | Go forward in time |
Hints
- g- goes back in time through all changes, g+ goes forward. This works across undo branches!
# Undo Tree Practice
# Make different changes and explore the undo tree
original_text = 'This is the original text'
# Experiment 1: Change to 'This is version ONE'
# Then undo (u)
# Experiment 2: Change to 'This is version TWO'
# Now you have created an undo branch!
# TODO:
# 1. Change the text to 'This is version ONE'
# 2. Press 'u' to undo
# 3. Change the text to 'This is version TWO'
# 4. Press 'g-' to go back in time (you'll see version ONE again!)
# 5. Press 'g+' to go forward in time
# 6. Explore: Try making more changes and using g- and g+