Hi Peter, Gary,

I will try out your suggestions. I think these methods are very useful
for novices.
Maybe the folding help should be expanded (no pun intended) with such examples,
Many users like myself just cut paste the vim help examples and get started.

thanks,
Mohsin.

On Fri, Jul 23, 2010 at 11:14 AM, Peter Odding <pe...@peterodding.com> wrote:
> Mosh wrote:
>>
>> I noticed gmail folds large mail when  contiguous lines have same prefix.
>>
>> It would also work for:
>> find . | vim -
>> and vim could fold directories recursively by number of slashes?
>>
>> Then users dont have to figure out the complexities of folding mode setup?
>> any ideas how to do it?
>
> Hi Mosh,
>
> I wrote an ftplugin/folddirs.vim script that I use to quickly scan the
> listings produced by `rsync -v` which on large file sets can generate output
> that far exceeds my manual reviewing capabilities :-)
>
> It folds based on the common prefix of lines which makes it really slow but
> on the other hand it does the job and I don't think there's an easy way to
> speed this up without reaching for C instead of Vim script.
>
> I've attached the script, if you save it as ~/.vim/ftplugin/folddirs.vim and
> then do :set ft=folddirs in the buffer containing the `find` output it
> should work.
>
>  - Peter Odding
>
> " A folding expression that folds contiguous pathnames based on common
> prefix.
>
> function! FoldDirs_Expr(lnum)
>  let a = split(getline(a:lnum - 1), '/')
>  let b = split(getline(a:lnum), '/')
>  let i = 0
>  while i < len(a) && i < len(b) && a[i] == b[i]
>    let i += 1
>  endwhile
>  return i
> endfunction
>
> function! FoldDirs_Text(foldstart, foldend)
>        let a = split(getline(a:foldstart), '/')
>        let b = split(getline(a:foldend), '/')
>  let i = 0
>  while i < len(a) && i < len(b) && a[i] == b[i]
>    let i += 1
>        endwhile
>        let common_path = join(a[0 : i - 1], '/')
>  let folded_lines = a:foldend - a:foldstart
>        return printf('%s: %d lines', common_path, folded_lines)
> endfunction
>
> setlocal foldexpr=FoldDirs_Expr(v:lnum)
> setlocal foldtext=FoldDirs_Text(v:foldstart,v:foldend)
> setlocal foldmethod=expr
> setlocal foldenable
>
> --
> You received this message from the "vim_dev" 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 from the "vim_dev" 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

Raspunde prin e-mail lui