preservim / vim-markdown

Markdown Vim Mode
4.7k stars 524 forks source link

Markdown folding #365

Open harryln opened 6 years ago

harryln commented 6 years ago

I have found out the folding is unstable. Some markdown files are fine with folding, but others not. Sometimes some files are OK but after adding some new contents, the folding disappears completely. I cannot figure out what makes folding gone. This is very annoyed. Any idea? Many thanks.

sidequestboy commented 6 years ago

Examples?

harryln commented 6 years ago

Hi there, this is the example.

I think it is 'r' for R language to prevent heading section fold. If I remove 'r', the heading section folding comes back after re-opening this file.

Any suggestion?


title: "Temp Notes" author: "harryln" date: "February 28, 2018"

Extract R code from Rmd document

This operation need package knitr.

library(knitr)                    ## extract R code only 
purl("test.Rmd")
purl("test.Rmd",
     output = "test2.R",
     documentation = 2)           ## also include documentation
tukoz commented 6 years ago

This behaviour « Some markdown files are fine with folding, but others not » with error E490: No fold found. also bugged my workflow. Until today when I finaly got rid of it.

I had

au BufWinLeave * mkview
au BufWinEnter * silent loadview

in my vim rc file to auto save/load the state of files I edit with vim. Getting rid of these two line then running :so $MYVIMRC had all my markdown files have the proper behaviour when it comes to folding.
Now I can read/edit long texts again on any device with a small screen thanks to vim and vim-markdown :dancing_women:

Related issues I know of: #334, #345.

tristanninet commented 6 years ago

I had the same problem "Some markdown files are fine with folding, but others not" with error E490: No fold found. Turned out what was causing that was fenced code blocks using "bash" as filetype:

```bash some code ```

The same with sh instead of bash causes no problem. This is definitely a bug (let's call it bug 1).

Furthermore, even though man page says about g:vim_markdown_fenced_languages option:

Default is "['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']".

This was not the case for me. This is another bug (bug 2).

Finally, setting g:vim_markdown_fenced_languages option to the value above did not fix bug 1.

tobinjt commented 5 years ago

The syntax highlighting for some other languages overrides necessary Markdown folding settings. E.g. a Markdown file I have that has shell and Vim fenced code blocks breaks folding, because Perl syntax has overwritten 'foldmethod': :verbose set foldmethod foldmethod=syntax Last set from /usr/local/Cellar/vim/8.1.1000/share/vim/vim81/syntax/perl.vim line 429

meonkeys commented 1 year ago

I would add: folding appears to affect performance. See #266