Keep markdown headings open when switching buffers?

26 views
Skip to first unread message

wolfv

unread,
Aug 13, 2015, 12:49:38 AM8/13/15
to vim_use
I use markdown files with #headings, a vim plug-in folds and unfolds the headings.

When I initially open a markdown file in vim, all the headings are folded.
I drill down through the headings to access a line.

I switch to another buffer, read a line, and then switch back to the previous buffer.

All the markdown headings are refolded :(
I have to drill down through the headings again to access the line I had unfolded.

Sometimes I need to reopen 2 or 3 headings.
Is there a way to keep the markdown headings open when switching buffers?
Or do you know of a markdown plugin with this desirable behavior?

Thank you.

Nikolay Pavlov

unread,
Aug 13, 2015, 12:53:06 AM8/13/15
to vim...@googlegroups.com
Vim should not automatically close fold unless instructed to by
'foldclose' option. Plugin may also though alter Vim behaviour, but I
think it is unlikely this is the case.

Also check out 'foldopen' option.

>
> Thank you.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Wolfram Volpi

unread,
Aug 13, 2015, 5:41:36 AM8/13/15
to vim...@googlegroups.com
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/scMXtFY6upk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thanks Nikolay Pavlov,

What you say agrees with the Vim manual:

help: fold-behavior > For manual folding the defined folds are restored.

help: fold-foldlevel > No manually opened folds will be closed.

I am not using the 'foldclose' option, and 'foldopen' option is not what I need.

The only thing in my vimrc file is for folding:

autocmd FileType markdown source /home/wolfv/vimfiles/ftplugin/markdown.vim

Is markdown.vim part of the default vim install?

markdown.vim and my small .vimrc file are attached.

.vimrc
markdown.vim

wolfv

unread,
Aug 13, 2015, 5:05:58 PM8/13/15
to vim_use
On Thursday, August 13, 2015 at 3:41:36 AM UTC-6, wolfv wrote:
> On Wed, Aug 12, 2015 at 10:52 PM, Nikolay Pavlov wrote:

>
>
> 2015-08-13 7:49 GMT+03:00 wolfv:
>
> > I use markdown files with #headings, a vim plug-in folds and unfolds the headings.
>
> >
>
> > When I initially open a markdown file in vim, all the headings are folded.
>
> > I drill down through the headings to access a line.
>
> >
>
> > I switch to another buffer, read a line, and then switch back to the previous buffer.
>
> >
>
> > All the markdown headings are refolded :(
>
> > I have to drill down through the headings again to access the line I had unfolded.
>
> >
>
> > Sometimes I need to reopen 2 or 3 headings.
>
> > Is there a way to keep the markdown headings open when switching buffers?
>
> > Or do you know of a markdown plugin with this desirable behavior?
>
>
>
> Vim should not automatically close fold unless instructed to by
>
> 'foldclose' option. Plugin may also though alter Vim behaviour, but I
>
> think it is unlikely this is the case.
>
>
>
> Also check out 'foldopen' option.
>
>
>
> >
>
> > Thank you.
>
> >
>
> > --
>
> > --
>
> > You received this message from the "vim_use" maillist.
>
> > Do not top-post! Type your reply below the text you are replying to.
>
> > For more information, visit http://www.vim.org/maillist.php
>
> >
>
> > ---
>
> > You received this message because you are subscribed to the Google Groups "vim_use" group.
>
>
>
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
>
> You received this message from the "vim_use" maillist.
>
> Do not top-post! Type your reply below the text you are replying to.
>
> For more information, visit http://www.vim.org/maillist.php
>
>
>
> ---
>
>
>
> Thanks Nikolay Pavlov,
>
>
> What you say agrees with the Vim manual:
>
>
>
> help: fold-behavior > For manual folding the defined folds are restored.
>
>
> help: fold-foldlevel > No manually opened folds will be closed.
>
>
> I am not using the 'foldclose' option, and 'foldopen' option is not what I need.
>
>
> The only thing in my vimrc file is for folding:
>
>
> autocmd FileType markdown source /home/wolfv/vimfiles/ftplugin/markdown.vim
>
>
> Is markdown.vim part of the default vim install?
>
>
> markdown.vim and my small .vimrc file are attached.

The only purpose of my small .vimrc file is folding.
It sources the markdown.vim file, which was copied from https://gist.github.com/vim-voom/1035030

wolfv

unread,
Aug 13, 2015, 11:04:18 PM8/13/15
to vim_use

The problem was solved by removing line 32 of https://gist.github.com/vim-voom/1035030

setl foldlevel=0

Now vim preserves folded state when switching buffers.

Thank you for your patients.

Reply all
Reply to author
Forward
0 new messages