How do I jump between sentences in Vim?
Answer
( and )
Explanation
How it works
Vim defines a sentence as text ending with ., !, or ? followed by either the end of a line, or by a space or tab. The sentence motions let you jump between these boundaries:
- ) moves the cursor forward to the beginning of the next sentence.
- ( moves the cursor backward to the beginning of the previous sentence.
These motions are particularly powerful when editing prose, documentation, commit messages, or comments where text is organized into natural language sentences.
Sentence motions also work as operators. For example, d) deletes from the cursor to the start of the next sentence, and c( changes from the cursor back to the start of the current sentence.
Example
Consider this paragraph:
The quick brown fox jumped over the lazy dog. It was a sunny day.
The birds were singing. All was well in the forest.
With the cursor at the start of the paragraph:
- Press
)to jump toIt was a sunny day. - Press
)again to jump toThe birds were singing. - Press
(to jump back toIt was a sunny day.
For code, sentence boundaries may not align with what you expect since code rarely ends with punctuation followed by whitespace in the traditional sense. For code navigation, paragraph motions { and } (which jump between blank lines) are usually more useful.
Sentence text objects
You can also operate on full sentences using text objects:
disdeletes the inner sentence (the sentence text itself).dasdeletes the sentence plus any trailing whitespace.visselects the sentence in visual mode.
These make it easy to restructure paragraphs without manual selection.