Course Lessons
Free Trial: 5 lessons remaining
Unlock Full Access
Text Objects with All Operators
Estimated time: 10 minutes
Task Instructions
Combine text objects with different operators for maximum power
Practice combining text objects with various operators. Use not just 'd' and 'c', but also 'y' for yanking, 'v' for visual selection, 'gU' for uppercase, 'gu' for lowercase.
Learning objectives
- Combine text objects with multiple operators
- Practice d, c, y, v with text objects
- Learn case changes with gU and gu
- Master the text object mindset
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.
g[Uu]
Use case change operators
[cdvy]i
Combine operators with text objects
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 |
|---|---|
| gUiw | Uppercase inner word |
| gui' | Lowercase inside quotes |
| dap | Delete around paragraph |
| yi( | Yank inside parentheses |
| vi{ | Select inside braces |
| =ip | Auto-indent paragraph |
Hints
- Text objects work with ANY operator
- gU = uppercase, gu = lowercase
- = operator auto-indents text objects
# Combining Text Objects with Operators
# Practice using text objects with different operators
def PROCESS_DATA(input_string):
# Make function name lowercase: guiw on PROCESS_DATA
result = calculate_value('make_this_uppercase') # gUi'
# Delete this entire comment block with dap
# This is unnecessary
# Remove all of this
items = ['keep', 'delete_me', 'keep'] # Use di' on middle item
config = {
'HOST': 'localhost', # Make lowercase: gui'
'port': 8080
}
# Select and examine this block with vip
# Then maybe delete it with dip
# Or change it with cip
return transform(result)
# TODO: Practice different operators with text objects
# 1. Use guiW to lowercase PROCESS_DATA
# 2. Use gUi' to uppercase string contents
# 3. Use dap to delete paragraph blocks
# 4. Use yi( to yank function arguments
# 5. Use vi{ to select dictionary contents