Friday, August 14, 2015

Re: Where in the vim script is "+-- N lines: " added to folded markdown headings?

On 2015-08-14, wolfv wrote:
> I am using vim 7.4 with
> markdown heading folding from https://gist.github.com/vim-voom/1035030
> and highlighting from /usr/share/vim/vim74/syntax/markdown.vim
>
> With this setup, folded headings are preceded by "+-- N lines: ", where N is the heading level.
> Unfolded headings are rendered as is.
> This causes folded and unfolded headings to misalign.
> In this example, heading3 is unfolded:
>
> +-- 37 lines: #heading1
>
> +-- 85 lines: #heading2
>
> #heading3
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
>
> +-- 16 lines: #heading4
>
> Where in the vim script are the "+-- N lines: " added to the folded markdown headings?
> I would like to change the vim script so that folded and unfolded headings align on the left, something like this:
>
> #heading1 :37 lines
>
> #heading2 :85 lines
>
> #heading3
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
>
> #heading4 :16 lines

Those lines aren't added by the script; they are added by Vim itself
and the foldtext() function, which is the default value of the
'foldtext' option. See

:help foldtext()
:help 'foldtext'
:help fold-foldtext

As described in those help topics, you can create your own
'foldtext' expression or function to format the fold lines as you
like.

As an example, here is the 'foldtext' function from my ~/.vimrc that
I use for almost all my folding.

set foldtext=MyFoldText()
function! MyFoldText()
let n = v:foldend - v:foldstart + 1
let i = indent(v:foldstart)
let istr = repeat(' ', i)
return istr . "+-" . v:folddashes . " " . n . " lines "
endfunction

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment