vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

Markdown folding

Open harryln opened this issue 7 years ago • 6 comments

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.

harryln avatar Mar 07 '18 11:03 harryln

Examples?

sidequestboy avatar Mar 22 '18 07:03 sidequestboy

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

harryln avatar Mar 24 '18 10:03 harryln

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.

tukoz avatar Jul 06 '18 12:07 tukoz

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.

tristanninet avatar Sep 10 '18 12:09 tristanninet

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

tobinjt avatar Mar 17 '19 18:03 tobinjt

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

meonkeys avatar Jan 19 '23 17:01 meonkeys