How do I visually select the text of a sentence without selecting surrounding whitespace?
Answer
vis
Explanation
The is (inner sentence) text object selects the sentence the cursor is in — excluding any leading or trailing whitespace that separates sentences. It is the inner counterpart to as (around sentence), which includes the surrounding whitespace.
How it works
venters Visual modeisselects the inner sentence: the sentence text itself, up to (but not including) the whitespace that follows the closing punctuation- A sentence ends at
.,!, or?followed by a space, tab, or end-of-line vas(around sentence) includes the trailing whitespace — used when deleting a sentence cleanly without leaving extra spaces- Works in Normal mode too:
disdeletes the inner sentence,cischanges it,yisyanks it
Example
Given this paragraph:
The quick brown fox jumps. A dog barked loudly. The end.
With the cursor on barked, pressing vis selects A dog barked loudly. (the sentence text, no trailing space). Pressing cis then lets you type a replacement sentence.
Tips
- The
is/asobjects are most useful when editing prose, comments, or docstrings - Use
(and)in Normal mode to jump between sentences before selecting - For programmatic text (where sentences are rare), prefer word (
iw), paragraph (ip), or block (iB) objects dipdeletes an inner paragraph;disanddiptogether let you clear text at two different granularities without losing your surrounding context