Saturday, May 26, 2012

Re: Folding on markdown headers

On Sat, May 26, 2012 at 06:47:59AM EDT, Eric Weir wrote:
> On May 25, 2012, at 10:12 PM, Chris Jones 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.

In other words, the standard setup should take care of turning on
highlighting immediately after you write the file when you use one
of the above file extensions (*.markdown, *.mdown, *.mkd, etc.)

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

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.

> I thought I was getting folding and highlighting on regular markdown
> files, i.e., "md," but when I checked just now it appears that I am
> not. So I put the auto command you suggested in your previous response
> in my .vimrc. Then I get folding and highlighting, but only when
> opening a previously saved file.

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

> > Did you download a syntax highlighting file from somewhere else? Do
> > you have any other 'markdown.vim' files on your system? Seems there
> > are 2-3 different syntax files lying around in different repos
> > (vim.org, github..).

> Again, I was under the impression that markdown support is now built
> in to Vim. Perhaps I am mistaken about that. I'll have to look into
> what syntax files are on my system. I don't believe I've added any to
> my Vim installation. Some [all?] of my plugins may have their own
> syntax files. I'm pretty sure one---VimWiki---does and it sets a fold
> method ['expr"], but only for VimWiki files. I'll check for others.

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.

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

Pretty much stumped at this point.. Maybe s/o with access to MacVim
could run a quick test & let us know whether it works on their system?

CJ

--
Alex Perez is aliveeeeeeee!!!


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