I'm using vim 8.2 on Win 10. I want to enable markdown folding with the built-in markdown.vim.
But it will not work. I have tried solutions from other questions (e.g., Enable Expr Folding in Markdown and How to fold markdown using the built-in markdown mode?), but to no avail.
My vimrc contains...
let g:markdown_folding = 1
let g:markdown_fenced_languages = ['vim', 'yaml', 'python', 'bash=sh', 'sql', 'git', 'make', 'html', 'css', 'javascript', 'js=javascript', 'json=javascript', 'xml']
syntax enable
set nocompatible
My file is detected as markdown, as shown here...
:filetype
returns detection:ON plugin:ON indent:ON
:set ft
returns markdown
:set foldmethod?
returns manual
:scriptnames
output includes...
27: C:\Program Files (x86)\Vim\vim82\ftplugin\markdown.vim
30: C:\Program Files (x86)\Vim\vim82\syntax\markdown.vim
I do not have a vimwiki
plugin (one user reported getting rid of vimwiki plugin solved the issue)
Yet zc
, zR
, zM
, and zo
all result in E490: No fold found
, no matter where I place the cursor (on the ##
, on the heading name, or inside the text associated with that heading)
Hmmm...
I just found another question regarding this topic (No folding of markdown files) which contains what seems to be a solution, but which is a bit beyond my vim skill level. Does anyone recommend I try that solution? I'd rather not unless it truly is the only solution to my problem.
Further info per comments...
:version
contains +folding
:verbose set foldmethod?
returns foldmethod=manual
markdown.vim contains the following if-statement..
if has("folding") && exists("g:markdown_folding")
setlocal foldexpr=MarkdownFold()
setlocal foldmethod=expr
setlocal foldtext=MarkdownFoldText()
let b:undo_ftplugin .= " foldexpr< foldmethod< foldtext<"
endif
has("folding")
is true
hasexists("g:markdown_folding")
is false
AHA!!!
.. and the reason markdown_folding was false? ...a typo in my gvimrc (!)
I fixed the typo and folding is operational!