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

  • @Tumbler41 No. It is not working for me. I tried let g:markdown_folding=1 and zM zR zo zc. Nothing works. Running Neovim 0.1.7. – deshmukh Sep 14 '17 at 15:46
  • This answer is true for Vim. I've never used Neovim and have no idea of the differences or idiosyncrasies of it. – Tumbler41 Sep 14 '17 at 15:49
  • @Tumbler41 OK. But it does not work on vim 8 also. I have let g:markdown_folding=1, ft=markdown and foldmethod=syntax. What am I missing? – deshmukh Sep 15 '17 at 7:03
  • Yea.. didnt work for vim8 either – alpha_989 Mar 6 '18 at 18:22
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.

  • E474: Invalid argument: foldmethod = E521: Number required after =: foldcolumn = – nilon Sep 30 at 16:11

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.