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?

2 Answers 2


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, 2017 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, 2017 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, 2017 at 7:03
  • Yea.. didnt work for vim8 either
    – alpha_989
    Mar 6, 2018 at 18:22
  • yeah, for me neither. I can't make it work :(
    – asa
    Apr 19, 2021 at 14:28

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, 2019 at 16:11
  • This answer works great. No plugins needed and just a small snippet added to your .vimrc file. The tip about removing the vimwiki plugin was the missing piece. Thank you sir! Mar 1, 2021 at 3:16

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.