Hi, and thanks a lot!

VOom is not what I had in mind but it seems to be even better! Also
thanks for the snippet for folding; I will give a look at it as I'm
still interested in the folding method.

Best,

Alex

On Jan 7, 11:53 pm, Vlad Irnov <[email protected]> wrote:
> On Jan 7, 10:16 am, Alexandre Leray <[email protected]>
> wrote:
>
> > Hi,
>
> > I'm maintaining markdown files using vim, and some of them are becoming
> > quite large. I'm looking for a vim plugin to fold the files according to
> > their H1-H6 markers (I'm using === and --- for h1 and h2). Do you know
> > any script to do that?
>
> > Best,
>
> > Alexandre Leray
>
> May I suggest my VOoM 
> plugin:http://www.vim.org/scripts/script.php?script_id=2657
> The latest version can outline Markdown
>         :Voom markdown
> It's more powerful than just folding.
>
> But if you must have folding, it should be easy to write a folding
> expression.
> Here is my attempt, not tested very well:
>
> " folding for Markdown headers, both style
> "http://daringfireball.net/projects/markdown/syntax#header
> setl foldmethod=expr
> setl foldexpr=Foldexpr_markdown(v:lnum)
> func! Foldexpr_markdown(lnum)
>     let l1 = getline(a:lnum)
>     " ignore empty lines
>     if l1 =~ '^\s*$'
>         return '='
>     endif
>     " next line is underline
>     let l2 = getline(a:lnum+1)
>     if  l2 =~ '^=\+\s*'
>         return '>1'
>     elseif l2 =~ '^-\+\s*'
>         return '>2'
>     " current line starts with hashes
>     elseif l1 =~ '^#'
>         return '>'.matchend(l1, '^#\+')
>     " keep previous foldlevel
>     else
>         return '='
>     endif
> endfunc

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

Reply via email to