On Tue, March 22, 2011 5:58 am, c b wrote:
> Hi Tom,
>
> Thanks for the expr. It works like a charm. I do have a couple of
> questions though 1. How can we expand this so that multiple nesting
> (based on timestamp) will be supported? i.e. if we have logs for two
> days 2011-03-20 and 2011-03-21, the first level would have only two
> lines shown (when folded) viz.  2011-03-20 and 2011-03-21. Then upon
> opening one of the folds, each would have upto 24 folds (one for
> each hour), then each hour would have upto 60 folds (one for each
> minute) and so on.

:set foldmethod=expr
foldexpr=FoldTimestamp(v:lnum)
fu! FoldTimestamp(lnum)
    let a=getline(a:lnum)
    if a>1
        let b=getline(a:lnum-1)
    else
        let b=getline(a:lnum+1)
    endif
    if a[:19] == b[:19] " Fold by second
       return 6
    elseif a[:16] == b[:16] " Fold by hour
       return 5
    " repeat for each item you want to compare with,
    " decrementing the return value
    else
       return 0
    endif
endfu

> 2. The [Other info] in the example is info I don't really care
> about. Is there a concept of a vertical fold/any way to hid the
> [Other info] fields?

No.

regards,
Christian

-- 
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

Reply via email to