I'm trying set up text inside default fold markers to be treated as a distinct paragraph. To see, in a new buffer:

:set foldmethod=marker

This is a paragraph 1
Want text inside this fold treated as a paragraph 2 (as well as the surrounding markers)
Finally, this would be paragraph 3

Currently vip on any line will select all lines. Desired outcome for vip depending on cursor line:

  • line 1: selects text on line 1 only
  • line 2-4: selects text of lines 2-4
  • line 5: selects text on line 5 only.

One solution is to add empty lines around any folds, but that is specifically what I am trying to avoid in this case.

I have experimented with adjusting :set paragraphs but have not found anything yet that has worked. I also tried set cpo+={ which helps with { motion operator, but not paragraph text object.

  • Thoughts: use .{{/.}} and :set paragraphs^={{}}, though I don't how like vip behaves in the middle there. Or, mess with [[ and ][ to jump between braces. Or, well, add newlines :)
    – D. Ben Knoble
    Jan 25, 2022 at 14:17
  • Thanks, this works quite well. I expected gqip on line5 to merge with line 4. but it appears lines with .nroff macros are not touched by gqip (despite being visually selected with vip ). Jan 28, 2022 at 16:38
  • If you have an answer that works for you, please post it!
    – D. Ben Knoble
    Jan 28, 2022 at 16:40
  • 1
    Your suggestion is so close. While gqip commands work in all three paragraphs, vip command on the bottom line selects the line above it. I tried putting placing nroff paragraph macro on lines 2 and 2 and 5. This works for both vip and gqip except gqip does not format a line that starts with an nroff macro. I also tried set fo+=w so that lines without a trailing whitespace count as end of paragraph, but that does not appear to work with vip motion operators. Jan 29, 2022 at 7:22
  • @D.BenKnoble I've been using your clever suggestion to combine the fold marker with the paragraph macro, and it's working great in practice. If you post as answer, I will mark it answered. Thanks for the help. Jan 31, 2022 at 21:50

1 Answer 1


An imperfect solution: use .{{,.}} as fold markers and :set paragraphs^={{}}. This is imperfect because of the way vip behaves with the start and end markers, but gqip works as intended.

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.