Course Lessons
Free Trial: 5 lessons remaining
Unlock Full Access
Visual Mode with Different Operators
Estimated time: 10 minutes
Task Instructions
Learn to combine visual selections with various operators like d, y, c, >
Practice combining visual selections with different operators like gu (lowercase), gU (uppercase), > (indent), and others to transform selected text efficiently.
Learning objectives
- Learn to combine visual selections with various operators
- Master using d, y, c, >, gu, gU with visual mode
- Understand how operators work with different visual modes
- Practice efficient text transformation workflows
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.
v
Use visual character mode
V
Use visual line mode
gu
Make selection lowercase
>
Indent 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{motion}{operator} | Apply operator to selection |
| gu | Make lowercase |
| gU | Make uppercase |
| > | Indent right |
| < | Indent left |
Hints
- After selecting text with v/V/Ctrl-v, you can apply operators: d (delete), y (yank), c (change), gu (lowercase), gU (uppercase), > (indent)
# Visual Mode with Operators Practice
# Use visual mode with different operators to transform this code
class UserManager:
def __init__(self):
self.USERS = [] # This should be lowercase
self.CONFIG = {} # This should be lowercase
def ADD_USER(self, user): # Function names should be lowercase
self.USERS.append(user)
def REMOVE_USER(self, user_id): # Function names should be lowercase
self.USERS = [u for u in self.USERS if u.id != user_id]
def GET_CONFIG_VALUE(self, key): # Function names should be lowercase
return self.CONFIG.get(key)
# TODO: Use visual mode with operators:
# 1. Select 'USERS' and use 'gu' to make it lowercase
# 2. Select 'CONFIG' and use 'gu' to make it lowercase
# 3. Select the ADD_USER function name and use 'gu' (or 'c' and retype)
# 4. Use visual line mode (V) on the entire ADD_USER method and indent with '>'
# 5. Select text inside quotes and change it