Friday, May 25, 2012

Re: Folding on markdown headers

On 2012-05-25, sc wrote:
> On Fri, May 25, 2012 at 06:35:28PM -0400, Eric Weir wrote:
>
> > On May 25, 2012, at 3:08 PM, Chris Jones wrote:
>
> > > On Tue, May 22, 2012 at 09:14:03AM EDT, Eric Weir wrote:
> > >
> > >>> On May 20, 2012, at 12:20 AM, Chris Jones wrote:
>
> > > What exactly do you mean by 'when I create a file'..? How does it 'not
> > > work'?
>
> > I start with an empty window, i.e., no file loaded. I type in a
> > "#" and some text, do a <CR> and some more text, another <CR>
> > and some more text, then write/save the file as a markdown file,
> > i.e., with markdown extent. At that point the header is not
> > highlighted and folding does not work. If I close the file and
> > reopen it, highlighting and folding work.
>
> when you start with an empty window, you have done nothing to
> tell vim what type of file you are going to create -- when you
> add text it still doesn't know -- if you write the file with a
> markdown extent, it COULD know if you would ask it to check
> (writing doesn't trigger filetype detection) -- so to ask it you
> might try something like
>
> :syntax enable
>
> perhaps that will help?

That depends on how the markdown filetype is being detected, by
filename extension or by file content.

If the markdown filetype is being detected by file content,
executing

:filetype detect

after you've written a number of lines of recognizable markdown
should work.

If the markdown filetype is being detected by filename extension,
you'll have to give your buffer a name, e.g.,

:f myfile

before executing

:filetype detect

The simplest may be to execute

:set ft=markdown

or whatever the markdown filetype is actually called, as soon as you
open a new, empty window.

Regards,
Gary

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