3

I'm writing a helpfile for a plugin, i.e. a foo.txt file that goes in the plugin's doc/ directory. At the bottom of that file I placed the following modeline:

vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0

Now here's the problem:

  • When opened directly with vim foo.txt, the file is displayed with the correct foldlevel of 0 (folds delimited by markers are closed), which means the modeline was correctly interpreted.
  • When opened as a help file within vim as :help foo, the file is displayed with folds opened, which means the modeline was not correctly interpreted.

So the question is: how do I get the folds to appear initialy closed when the helpfile is opened with :help?

Is it even possible?

Note that the problem can be tested (and hopefully reproduced) by copying the following code to e.g. ~/.vim/doc/foo.txt

*foo*
{{{
This line should appear initially folded
}}}
vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0

then comparing what happens with

> vim ~/.vim/doc/foo.txt

vs.

> vim
:helptags ~/.vim/doc/
:help foo
2

Vim treats help files special and resets some options beofre opening them. After trying your example, what seems to work is to add an explicit :set foldenable to your modeline, e.g. this seems to work for me:

vim: tw=70 ft=help fdm=marker fmr={{{,}}} fdl=0 fen

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.