Saturday, May 26, 2012

Re: Folding on markdown headers

On May 26, 2012, at 6:32 PM, Chris Jones wrote:
>
>> On Sat, May 26, 2012 at 06:47:59AM EDT, Eric Weir wrote:
>>
>> I don't know when it became effective, but my understanding is that
>> markdown support is built into Vim.
>
> I ran a quick test on a freshly-installed Vim 7.3 and highlighting
> worked out of the box with a 20-line markdown sample I grabbed online.
>
> With Vim 7.3, $VIMRUNTIME/filetype.vim has the following lines:
>
> | " Markdown
> | au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown
>
> As soon as I issued a ':w /tmp/sample.mdown' to write the [No Name]
> buffer to disk , the markdown was highlighted.

Thanks, Chris. I did same with an ".mkd" extent and got the same result. I'm embarrassed to say this, but I think all this "sturm und drang" is going to turn out to have been occasioned by the fact that I mistakenly believed that ".md" was a markdown extent.

> I would avoid '*.mmd' & '*.md' (not in the above list). Worse, per
> filetype.vim, '*.md' is something else: a modula2 file extension.

No problem with ".md", but ".mmd" is the extent used by multimarkdown, an extension of markdown that adds some additional features, e.g., footnotes. It is used by Scrivener to convert Scrivener documents to LaTeX. Without the ".mmd" extent multimarkdown will not compile the file.

> I proceeded to copy the folding script to ~/.vim/after/ftplugin/ under
> 'markdown.vim' and ran the same test. Sure enough, immediately after
> I wrote the buffer to disk (:w /tmp/sample2.mdown) my 20 lines became
> one single big fold.

Again, same result.

> Please remove... The 'au...' command above does the same thing. But the
> fact that in your case, highlighting does not work on file creation is
> interesting. As if Vim was never notified of the BufNewFile event..

Will do.

> Immediately after you create the file you could check that the folding
> script is loaded : run ':scriptnames' and look for a line that says
> ~/.vim/after/ftplugin/markdown.vim (or the MacVim equivalent).
>
> You need to do this on a dedicated Vim session.. start Vim on an empty
> buffer, enter some markdown, save the file, and run :scriptnames.. If
> the folding script isn't even loaded, folding is not going to work.

Safe to assume the script is loaded since I'm getting folding on recognized markdown files?

> Then run ':verbose set ft' and ':verbose set syntax' to see if they are
> set to 'markdown' and then ':verbose set fdm'.. should say 'expr'.

All results are positive.

I think this solves the problem. My apologies to everyone who was scratching their heads on this one when all along it was a stupid mistaken assumption on my part.

Not that it wasn't educational, though. So also thanks for that.

I owe responses to several others here, but at this point will get to that tomorrow.

Sincerely,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA
eeweir@bellsouth.net

"Style is truth."

- Ray Bradbury

--
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

No comments:

Post a Comment