On 6/26/13, Oliver Rath <rath@mglug.de> wrote:
> Hi list,
>
> Im looking for some expression to fold the output of tree command, i.e.:
>
> ├── opt
> ├── run -> /run
> ├── spool
> │ ├── anacron
> │ ├── asterisk [error opening dir]
> │ ├── cron
> │ │ ├── atjobs
> │ │ ├── atspool
> │ │ └── crontabs
> │ ├── cups [error opening dir]
> │ ├── libreoffice
> │ │ └── uno_packages
> │ ├── lintian
> │ ├── mail -> ../mail
> │ ├── plymouth
> │ ├── rsyslog
> │ └── samba
> └── tmp
>
> So imho I have to find a way to count the number of "│" (including the
> following spaces), so i could define a rule to open/cloes the folds
> recursivly. Any idea for an appropriate expression doing this?
>
> Tfh!
> Oliver
The following assumes that 'encoding' is a Unicode encoding. Vim thus
uses utf-8 internally, and each drawing char in your sample is 3
bytes.
func! FoldTree(lnum)
let ind = match(getline(a:lnum),'├\|└')/4+1
let indn = match(getline(a:lnum+1),'├\|└')/4+1
return indn>ind ? '>'.ind : ind-1
endfunc
setl fen fdm=expr fde=FoldTree(v:lnum)
Regards,
Vlad
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment