masukomi / vim-markdown-folding

Fold markdown documents by section.
248 stars 43 forks source link

Folds open on save #24

Open AmaruCoder opened 8 years ago

AmaruCoder commented 8 years ago

Is there any way to prevent the folds to open on save?

Miesco commented 7 years ago

AmaruCoder, I just used :mkview and :loadview to save and restore my folds to state before saving. I had a filter on my files before writing to the file that caused the current fold state to reset.

AmaruCoder commented 7 years ago

El Paso, August 28, 2016

Dear Drew,

Thank you, very much. Cordially,

José

On Aug 27, 2016, at 2:44 AM, Miesco notifications@github.com wrote:

Hi AmaruCoder, I wrote this until a fix is made. It allows folding and by nesting or not, and it does not fold or unfold on save:

let g:markdown_foldnested = 1 function MarkdownLevel() let h = matchstr(getline(v:lnum), '^#+') if empty(h) return "=" else if exists("g:markdown_foldnested") && g:markdown_foldnested == 1 return ">" . len(h) else return ">1" endif endif endfunction augroup markdown_fold au!

autocmd FileType markdown setl foldexpr=MarkdownLevel()
autocmd FileType markdown setl foldmethod=expr

augroup END — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nelstrom/vim-markdown-folding/issues/24#issuecomment-242905217, or mute the thread https://github.com/notifications/unsubscribe-auth/ACmQ6xtyKZhGJDZRfMo20WSkmhcMdKyXks5qj_jngaJpZM4JCbTd.