Hi shawn!

On Di, 13 Nov 2012, shawn wilson wrote:

> On Tue, Nov 13, 2012 at 9:50 AM, Christian Brabandt <[email protected]> 
> wrote:
> > On Tue, November 13, 2012 10:33, shawn wilson wrote:
> >> is there a way to specify how a fold gets labeled? the default (of the
> >> first line with visible text is generally correct) but sometimes, my
> >> fold will start at a line with only /* or // or #. and a fold label
> >> with one of these is next to useless.
> >>
> > See
> > :h 'foldtext'
> > :h fold-foldtext
> >
> 
> per foldtext -
> Leading white space, "//" or "/*" and the text from the 'foldmarker'
> and 'commentstring' options is removed.
> 
> i have:
> let perl_fold=1               " Perl
> and try:
> autocmd FileType perl set commentstring='# %s'
> 
> but, this doesn't seem to do anything.
> 
> also, it seems i was wrong about // - that does seem to work correctly in js

I am not sure, what you are trying to do here. But here is an example of 
how I customize my folded text. It is based on an idea by Greg Sexton 
mentioned at  
http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/



regards,
Christian
-- 
Sprachlexikon-Namen: AXEL - Schwitzige Muffel-Höhle

-- 
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
" Customized version of folded text, idea by 
" http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
fu! CustomFoldText() "{{{1
    "get first non-blank line
    let fs = v:foldstart
    while getline(fs) =~ '^\s*$' | let fs = nextnonblank(fs + 1)
    endwhile
    if fs > v:foldend
        let line = getline(v:foldstart)
    else
        let line = substitute(getline(fs), '\t', repeat(' ', &tabstop), 'g')
    endif
    " remove foldmarker from line
    let line = substitute(line, matchstr(&l:cms,
                \ '^.\{-}\ze%s').split(&l:fmr,',')[0].'\d\+', '', '')

    let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
    let foldSize = 1 + v:foldend - v:foldstart
    let foldSizeStr = " " . foldSize . " lines "
    let foldLevelStr = repeat("+--", v:foldlevel)
    let lineCount = line("$")
    let foldPercentage = printf("[%.1f", (foldSize*1.0)/lineCount*100) . "%] "
    let expansionString = repeat(".", w - 
strwidth(foldSizeStr.line.foldLevelStr.foldPercentage))
    return line . expansionString . foldSizeStr . foldPercentage . foldLevelStr
endf

set foldtext=CustomFoldText()

Reply via email to