Course
Free Trial: 5 lessons remaining
Unlock Full Access
Practice
Beginner
10 min
Paragraph & Sentence Objects
Text Objects: Speaking Vim's Language
Task Instructions
Work with larger text units using paragraph and sentence objects
Use paragraph and sentence text objects for larger text manipulations. Use dap to delete entire paragraphs, cip to rewrite paragraph contents.
Learning objectives
- Master paragraph objects: ip (inner paragraph) and ap (around paragraph)
- Learn sentence objects: is and as
- Practice moving and editing text blocks
- Understand how Vim defines paragraphs and sentences
Required keystrokes
Your submission is checked for these keystrokes, not just the final text — so reach for the technique, not a workaround.
- [cd]ap Use paragraph objects
- [cdv]i[ps] Use text objects
Helpful commands
- dap
- Delete a paragraph
- cip
- Change inner paragraph
- vap
- Select around paragraph
- dis
- Delete inner sentence
- yas
- Yank around sentence
Stuck? Peek at a hint 3 hints · try it on your own first
- Paragraphs are separated by blank lines
- ap includes the blank lines, ip doesn't
- Great for moving functions or text blocks
# Paragraph Objects Practice
# Use paragraph objects to reorganize this code
def old_function():
# This entire function needs to be deleted
print('Delete me!')
x = 1
y = 2
return x + y
def important_function():
# This function stays
result = calculate()
return result
# This comment block
# needs to be completely
# rewritten with better docs
def another_function():
# Implementation here
pass
'''
This is an old docstring
that needs to be updated.
Use cip to rewrite just the content.
'''
# TODO: Practice paragraph objects
# 1. Position cursor in old_function and use dap to delete it
# 2. Use cip to change paragraph contents (keeps blank lines)
# 3. Use cap to change including surrounding blank lines
# 4. Try vap to visually select a paragraph