3

Looking at the ftplugin file for markdown in Vim, it certainly appears that folding is supported, but I cannot get folding to work.

If I have some content like this:

# A heading

Some content.
More content.

How do I fold up this heading and its content?

3

Markdown folding:

As ana found out, for markdown specifically make sure that you have let g:markdown_folding = 1 or folding wont be "turned on".

General folding tips:

Vim won't fold automatically, try putting your cursor over the text and doing zc. This should close the fold.

If you want some visual context even when it's not folded try the foldcolumn option!

set foldcolumn=2

For more info see :h zo and :h foldcolumn

  • Thanks, but it doesn't fold at all. It says "no fold found". Is that expected? – ana Sep 14 '16 at 21:13
  • I tried the fold expression in the link and it worked for me. So maybe the expression isn't getting triggered? Are you sure that the language file is getting loaded? – Tumbler41 Sep 14 '16 at 22:31
  • The file is included as part of Vim, so I don't see why not. How would I confirm that it is being loaded? – ana Sep 15 '16 at 14:06
  • 3
    Figured it out. Turns out I need to let g:markdown_folding=1 for folding to work. – ana Sep 15 '16 at 14:13
  • Ah, yes. I see that now. Good catch. – Tumbler41 Sep 15 '16 at 14:40
0

I enable folding in markdown files by using the following in my .vimrc:

set foldmethod = manual
set foldcolumn = 1
highlight Folded ctermbg = NONE
highlight FoldColumn ctermbg = NONE
let g:markdown_folding = 1
let g:markdown_enable_folding = 1

Yet, folding was failing with the message "no folding found" until I removed the vimwiki plugin.

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.