Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion fold label

Received: by 10.204.129.9 with SMTP id m9mr1817970bks.1.1352834213795;
        Tue, 13 Nov 2012 11:16:53 -0800 (PST)
X-BeenThere: vim_use@googlegroups.com
Received: by 10.204.12.210 with SMTP id y18ls851861bky.6.gmail; Tue, 13 Nov
 2012 11:16:33 -0800 (PST)
Received: by 10.204.145.215 with SMTP id e23mr1056339bkv.0.1352834193823;
        Tue, 13 Nov 2012 11:16:33 -0800 (PST)
Received: by 10.204.145.215 with SMTP id e23mr1056338bkv.0.1352834193802;
        Tue, 13 Nov 2012 11:16:33 -0800 (PST)
Return-Path: <cbli...@256bit.org>
Received: from 256bit.org (linetics.de. [85.214.140.184])
        by gmr-mx.google.com with ESMTPS id v13si888197bkw.0.2012.11.13.11.16.33
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 13 Nov 2012 11:16:33 -0800 (PST)
Received-SPF: neutral (google.com: 85.214.140.184 is neither permitted nor denied by best guess record for domain of cbli...@256bit.org) client-ip=85.214.140.184;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.214.140.184 is neither permitted nor denied by best guess record for domain of cbli...@256bit.org) smtp.mail=cbli...@256bit.org
Received: from chrisbra by 256bit.org with local (Exim 4.72)
	(envelope-from <cbli...@256bit.org>)
	id 1TYLyL-0004Oz-DC
	for vim_use@googlegroups.com; Tue, 13 Nov 2012 20:16:33 +0100
Date: Tue, 13 Nov 2012 20:16:33 +0100
From: Christian Brabandt <cbli...@256bit.org>
To: vim_use@googlegroups.com
Subject: Re: fold label
Message-ID: <20121113191633.GB11655@256bit.org>
Mail-Followup-To: vim_use@googlegroups.com
References: <CAH_OBieuHFtCcny7MvJ6192eSa24uHbEmei15QgtcSBwJRqmqA@mail.gmail.com>
 <64b2381ed85d1261f5f66e5b0189da71.squirrel@comm.256bit.org>
 <CAH_OBie7OW=gCNhycCaLZ+pWdmp5k-pfMaAUvrfsT2_yh9q4Cw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <CAH_OBie7OW=gCNhycCaLZ+pWdmp5k-pfMaAUvrfsT2_yh9q4Cw@mail.gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)


--k+w/mQv8wyuph6w0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Hi shawn!

On Di, 13 Nov 2012, shawn wilson wrote:

> On Tue, Nov 13, 2012 at 9:50 AM, Christian Brabandt <cbli...@256bit.org> 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

--k+w/mQv8wyuph6w0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="CustomFoldText.vim"

" 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()

--k+w/mQv8wyuph6w0--