Course Lessons
Free Trial: 5 lessons remaining
Unlock Full Access
Visual Mode Best Practices
Estimated time: 10 minutes
Task Instructions
Master efficient visual mode workflows and common patterns
Practice common visual mode patterns and learn when visual mode is the best tool versus using normal mode operations. This lesson focuses on practical patterns used by Vim professionals.
Learning objectives
- Master efficient visual mode workflows
- Learn when to use visual mode vs normal mode operations
- Practice common visual mode patterns
- Understand visual mode best practices
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.
[vV]
Use visual mode
gv
Re-select last selection
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 |
|---|---|
| V | Visual line mode |
| v | Visual character mode |
| Ctrl+v | Visual block mode |
| gv | Re-select last visual selection |
| > | Indent selected text |
| o | Switch cursor to other end of selection |
Hints
- Visual mode is great for complex selections, but normal mode operations can be faster for simple edits
- Use gv to re-select your last visual selection
- Combine visual mode with operators like d, c, >, <, gU, gu
# Visual Mode Best Practices
# Practice efficient visual mode patterns
class UserManager {
constructor() {
this.users = [];
this.activeUsers = [];
this.bannedUsers = [];
}
// These methods need to be reordered alphabetically
removeUser(id) {
// Remove user logic
}
addUser(user) {
// Add user logic
}
updateUser(id, data) {
// Update user logic
}
banUser(id) {
// Ban user logic
}
getUser(id) {
// Get user logic
}
}
# TODO: Practice these visual mode patterns:
# 1. Use V to select entire methods and reorder them alphabetically
# 2. Use Ctrl+v to add '//' comment markers to multiple lines
# 3. Use v to select and change variable names
# 4. Practice using gv to re-select your last selection
# 5. Use visual mode with > to indent blocks