au BufEnter *.md setlocal foldexpr=MarkdownLevel() au BufEnter *.md setlocal foldmethod=expr au BufEnter *.md setlocalfoldtext=MarkdownFoldText()
MarkdownLevel函数负责找出折叠行以及当前层级
为什么返回的是”>4”或是”=”这种符号呢?
可以通过: help fold查看文档
1 2 3 4 5 6 7 8 9 10 11 12 13
value meaning 0 the line is not in a fold 1, 2, the line is in a fold with this level -1 the fold level is undefined, use the fold level of a line before or after this line, whichever is the lowest. "=" use fold level from the previous line "a1", "a2", add one, two, .. to the fold level of the previous line, use the result for the current line "s1", "s2", subtract one, two, .. from the fold level of the previous line, use the result for the next line "<1", "<2", a fold with this level ends at this line ">1", ">2", a fold with this level starts at this line