42

Right now I'm working with some blocks of text that are over 1000 lines long. Is there a simple way to move to the beginning of the next paragraph?

My workaround for now is searching for two consecutive newline characters:

/\n\n

Another workaround would be vip Esc j

  • vip visually select in paragraph (which also takes you to the end of the paragraph)

  • Esc Escape from visual selection

  • j move down

2
  • I think you meant vap<Esc>j, right? Too bad there's no 'previous paragraph' equivalent.
    – awvalenti
    Commented Mar 19 at 11:49
  • @awvalenti vap<Esc>j and vip<Esc>j seem to give the same results here. Thanks for pointing out an alternative. Also, vapo<Esc>kk will get you two lines before the current paragraph. Commented Mar 26 at 15:49

1 Answer 1

60

Yes, you can use the } and { paragraph motions to move a paragraph forwards or backwards.

From :help paragraph:

A paragraph begins after each empty line, and also at each of a set of paragraph macros, specified by the pairs of characters in the 'paragraphs' option. The default is IPLPPPQPP TPHPLIPpLpItpplpipbp, which corresponds to the macros .IP, .LP, etc. (These are nroff macros, so the dot must be in the first column). A section boundary is also a paragraph boundary. Note that a blank line (only containing white space) is NOT a paragraph boundary.
Also note that this does not include a '{' or '}' in the first column. When the '{' flag is in 'cpoptions' then '{' in the first column is used as a paragraph boundary posix.

Like you would expect, you can of course add a count and/or operator; eg. 2} to move 2 paragraps fowards. Or to delete the previous 2 paragraphs you can use 3d{.

Also see :help object-motions

5
  • 3
    Side note: very useful for programmers is also [[ and ]] (as well as [] and ][) to jump between beginning (and end) of functions.
    – Shahbaz
    Commented Mar 5, 2015 at 15:53
  • 2
    Unfortunately those function-jumping motions only really work if the opening brace is in the first column. I worked somewhere which put the functions' opening braces at the end of the function declaration line and the suggested tweaks in the docs never worked terribly well. :( Commented Oct 6, 2017 at 21:44
  • Very interesting: "Note that a blank line (only containing white space) is NOT a paragraph boundary." Commented Oct 23, 2023 at 15:09
  • @ChristopherBottoms In some vim plugins (namely for VS and VSCode), white space lines are considered paragraph boundaries, which I think is a better behavior since you can't exactly discern them visually otherwise. I wonder if there's a switch somewhere... Commented Mar 23 at 22:28
  • @ReiMiyasaka Good question. I was quoting from the help info in MartinTournoij's answer. I found this: stackoverflow.com/a/3939481/215487. "change vim paragraph separator" may be the magic search words in this case Commented Mar 25 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.