Sunday, January 15, 2012

Re: foldtext question

On 2012-01-15, AK wrote:
> On 01/15/2012 01:56 PM, Gary Johnson wrote:
> >On 2012-01-15, AK wrote:
> >
> >>It does work for me but I'm dealing with lines that have
> >>leading spaces and I add leading spaces, here is a relevant
> >>snip:
> >>
> >> let l = getline(v:foldstart)
> >> let line = substitute(l, '^[ ]*', '', '')
> >> let prefix = repeat(' ', (strlen(l) - strlen(line)))
> >> let c = ''
> >> if l =~ '^\s*class\s' | let c = '(c)--' | endif
> >> let line = prefix . '+--' . c . ' ' . line
> >
> >You can also use the indent() function to get the indentation of the
> >line directly instead of calculating string lengths, e.g.,
> >
> > let n = v:foldend - v:foldstart + 1
> > let i = indent(v:foldstart)
> > return repeat(' ', i) . "+-" . v:folddashes . " " . n . " lines "

> Thanks! I know that now, but I wrote this function a
> long time ago.. -ak

You're welcome. I should thank you, too. I also wrote my function
a long time ago and until now used a while loop instead of repeat()
to create the indent prefix.

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: