Folding in markdown files

151 views
Skip to first unread message

Maral Watanabe

unread,
Jan 10, 2020, 8:41:06 PM1/10/20
to vim_mac
Hi,

I store all my notes in a vimwiki with markdown syntax. 
These are the relevant settings from my .vimrc:

let g:vimwiki_table_mappings=0
let g:vimwiki_table_auto_fmt=0
let g:vimwiki_folding='expr'

let g:vimwiki_ext2syntax = {'.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
let g:vimwiki_list = [{'path': '~/Documents/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}, ... ]

When I try to fold sections in a note I encounter a very strange behavior.

Suppose this is the note document and the cursor is located at <cursor> and I am in normal mode (Screen_1):

Title: Some Titel

<cursor># Header

some line

## Section

section line

When I press zc to close the folding I receive this error: E490: No Fold found.

Then I cycle through the opened tabs by typing gt until I am back in the tab of the above note. Now the folding of the Header is closed, 
i.e. the content of the tab is like this (Screen_2):

Title: Some Titel

<cursor># Header [7] --------------------------------------------------------------------------
~
~

Now I can open the folding of the Header with zo and close it with zc
But when I wait a few seconds without hitting any key while the buffer is shown like in Screen_2 
MacVim opens the entire folding of Header, i.e. it automatically switches the buffer back to Screen_1.
After that automatic expansion of the folding of Header MacVim forgets the folding it has used before.
Now, when I try to close the folding with zo I again receive the error  E490: No Fold found.

Is this a known issue of MacVim? Does anyone have an idea why this behaviour occurs?

By the way: At work I use gVim (with almost the same settings in my vimrc) under Windows 10 and Ubuntu 16.04.
In gVim I encounter no such issues when I use fold commanads like zc and zo.

My MacVim version is: Custom Version 8.1.2234 (161)

Ciao

Maral

Tony Mechelynck

unread,
Jan 10, 2020, 9:17:07 PM1/10/20
to vim_mac
I don't think this issue is peculiar to MacVim (though I could be mistaken); but it could be a bug in Vim 8.1.2234. Which version of gvim are you using at work? It can be seen from the top part of the output of the :version command, once you are running that gvim version. You can capture that output, for instance in the clipboard (see :help :redir — and the clipboard is register +). You don't need to answer with the full output of :version, the interesting part is the top part, up to and including the line which ends with "Features included (+) or not (-)", you can remove the part after that, after pasting and before sending.

If your gvim version is not 8.1.2234, you can see a one-line description of each Vim patch, for version 8.1 at http://ftp.vim.org/pub/vim/patches/8.1/ and for 8.2 at http://ftp.vim.org/pub/vim/patches/8.2/ ; I don't think the difference between the last patchlevel of 8.1 and version 8.2.0 is related to folding so if there is something relevant to your problem it should be listed on one of these two pages.

The latest Vim source as of this writing is 8.2.110; if your gmail version at work is later than your MacVim version, then maybe you can try and find a later MacVim?

Best regards,
Tony.

Maral Watanabe

unread,
Jan 14, 2020, 9:40:18 AM1/14/20
to vim_mac

Hi,


I tried to analyze under which situation the problem arises. I use these versions of vim

  • MacBook
    •   MacVim: Custom Version 8.1.2234 (161)
  •  Work
    •   Windows 10: gVim 8.1.1817
    •   Ubuntu 16.04 (work): 7.4.1689

In both environments at work, the issue did not arise.


Then I set up a virtual machine running Ubuntu 16.04. on my MacBook. In the virtual machine, vim is of version 7.4.1689, i.e. the same version as in my Ubuntu environment at work. But although I installed the same plugins in both Ubuntu environments the issue with folding did only arise in the virtual machine on my MacBook. So I checked the versions of the plugins. It turned out that I used older versions of the following plugins in my environments at work:

After I had updated those plugins to the most recent versions in both environments at work the issue with folding also occurred at work in the Ubuntu environment but not in the Windows 10 environment. Hence my conclusion is that vim-markdown and vimwiki are incompatible in these versions of vim:

  • 7.4.1689
  • Custom Version 8.1.2234 (161)

but compatible in version 8.1.1817. So I guess there was a bug in version 7.4 which was fixed in 8.1 but somehow shows up again in the more recent version of MacVim. Another possibility would be that the recent version of either vim-markdown or vimwiki has some bug. But that's not me to find out.


Ciao


Maral

Tony Mechelynck

unread,
Jan 15, 2020, 4:45:40 AM1/15/20
to vim_mac


On Saturday, January 11, 2020 at 2:41:06 AM UTC+1, Maral Watanabe wrote:
I don't see these two plugins (filetype-pligins?) on my system. I hope someone else can help you.

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages