Friday, May 25, 2012

Re: Folding on markdown headers

On Fri, May 25, 2012 at 07:17:57PM EDT, Gary Johnson wrote:
> On 2012-05-25, sc wrote:

[..]

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

Not sure it's necessary.

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

Eric's previous post says he writes it as a markdown file - i.e. with
a markdown extent. So I assume that the file type is detected via the
filename extension.

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

There are things I find a little unclear regarding autocommands but
assuming the file extension is something like '*.mkdwn' shouldn't it be
possible to achieve this automatically when creating the file by placing
something like this in a file named ~/.vim/ftdetect/markdown.vim:

| autocmd BufNewFile,BufRead *.mkdwn set filetype=markdown

Wouldn't this cause ':w myfile.mkdwn' to automatically enable the
markdown foldexpr and create the folds in one pass?

CJ

--
ALL YOUR BASE ARE BELONG TO US!

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