How do I move forward or backward by sentence in Vim?
Answer
) and (
Explanation
The ) and ( motions move by sentence boundaries. A sentence in Vim ends with ., !, or ? followed by whitespace or end of line. This is extremely useful for navigating and editing prose, comments, documentation, and commit messages.
How it works
)moves forward to the start of the next sentence(moves backward to the start of the current or previous sentence- Vim defines a sentence as ending with
.,!, or?followed by a space, tab, or end of line - Accepts a count:
3)jumps forward 3 sentences
Example
Given this paragraph with the cursor at the start:
Vim is a text editor. It was created by Bram Moolenaar. It is
based on the vi editor.
Pressing ) moves to It was created..., pressing ) again moves to It is based....
Tips
- Use
dasto delete a sentence (around sentence text object) - Use
cisto change the current sentence - Combine with operators:
d)deletes from cursor to end of sentence - Works well for editing commit messages, docstrings, and markdown files