Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim expand selection by a paragraph

Tags:

vim

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?

like image 364
cambunctious Avatar asked Jun 21 '26 02:06

cambunctious


1 Answers

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.

like image 160
perelo Avatar answered Jun 25 '26 01:06

perelo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!