cambunctious
cambunctious

Reputation: 9582

Vim expand selection by a paragraph

If I have a visual selection in vim, how do I expand the selection to include the next paragraph? Also can I press o and do the same to select the previous paragraph?

Upvotes: 3

Views: 1338

Answers (1)

perelo
perelo

Reputation: 495

You can use the ap or ip text-objects for "a paragraph" or "inner paragraph". A paragraph is a block of text separeated by blank lines. ap also includes the blank lines after the current paragraph. There is also { and } motions to move amongst paragraphs.

So to get the next paragraph you can do 2} or }ap.

For the previous paragraph, indeed, use o to go to the other end of your selection and 2{.

You can also add a count to ap, e.g 2ap will select the current and the next paragraph.

Upvotes: 7

Related Questions