0

I am trying to set foldmarker={{{,\n\n\n, so that {{{ starts a fold and two consecutive empty lines end a fold. However, vim treats this as equivalent to foldmarker={{{,nnn. Is it possible to use newlines in a fold marker in this way?

  • 1
    What if you double escape the backslashes? \\n ? – D. Ben Knoble Apr 12 at 1:02
  • @D.BenKnoble Then it looks for a literal \n\n\n – ngenisis Apr 12 at 3:37
  • What about execute 'set foldmarker={{{,^VEnter' (use <C-v> to type a literal Enter three times)? – D. Ben Knoble Apr 12 at 12:49
3

fold-marker

The entry for foldmarker notes that:

The marker is a literal string (a regular expression would be too slow).

...so you don't have full use of all the usual escapes sequences.

The section option-backslash shows that the arguments to "set" can include a backslash to escape whitespace, quotemarks, or backslashes themselves. But it doesn't appear to be possible to escape a newline this way (because that still ends the "set" command).

fold-syntax

You can instead set multiline fold markers using syntax folding.

syn region myFold start="{{{" end="\n\n\n" transparent fold
syn sync fromstart
set foldmethod=syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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