How do I quickly change an entire sentence in Vim?
Answer
cis
Explanation
The cis command deletes the entire sentence under the cursor and drops you into insert mode, ready to type a replacement. It uses Vim's built-in sentence text object, which understands punctuation-based sentence boundaries — a feature most Vim users never discover.
How it works
cis the change operator (delete and enter insert mode)isis the "inner sentence" text object- Vim defines a sentence as text ending with
.,!, or?followed by whitespace or end-of-line isselects the sentence content without trailing whitespace, whileas("a sentence") includes the trailing whitespace
Example
Given the text with the cursor anywhere on the second sentence:
Vim is powerful. It has many features. Learn them all.
Pressing cis deletes It has many features and enters insert mode:
Vim is powerful. |. Learn them all.
Type The dot command is essential and press <Esc>:
Vim is powerful. The dot command is essential. Learn them all.
Tips
- Use
dasto delete a sentence and the trailing whitespace, cleaning up spacing automatically disdeletes the sentence without entering insert modeyisyanks (copies) the current sentencevisvisually selects the sentence so you can see what will be affected before acting- The
)and(motions move forward and backward by sentence — useful for navigating prose - Sentence text objects work best with properly punctuated text; they may behave unexpectedly with code that uses dots in identifiers like
object.method - Pair with
.to repeat: aftercis, type your replacement, press<Esc>, navigate to another sentence, and press.to replace it the same way