On 2010-07-23, 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?
The way to implement such features is to use 'foldexpr'. For your
'find' example, you could
:set foldmethod=expr
:set foldexpr=len(split(getline(v:lnum),'/'))
You could do something similar for the gmail example, setting
'foldexpr' to the number of leading >s in each line.
Putting the gmail folding code into a mail ftplugin would load and
execute it automatically for mail files. Triggering folding
automatically for the 'find' case would be a little trickier, but
could be done by creating a new filetype "find", detecting that
filetype by searching the buffer for lines matching the pattern of a
path, and putting the folding code into a find.vim ftplugin.
HTH,
Gary
--
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