I have a list of files grouped by file extension. I am trying to create 
a fold for each of the groups. For this purpose I created the following 
Vim function:
function! FoldByExtension()
    let s:searchSave = @/
    let s:wrapscanSave = &ws
    set nowrapscan
    normal zE
    1
    while 1
        try
            .,/\v^.*\.(.*)\n(.*\.\1\n)*\zs.+(\1)@<!$/-1fold
            normal nj
        catch /E385/
            break
        endtry
    endwhile
    .,$fold
    let &ws = s:wrapscanSave
    let @/ = s:searchSave
endfunction

With re=1 Vim correctly processes the following list:
#v+
foo.bat
bar.bat
baz.bat
foo.com
bar.com
baz.com
foo.txt
bar.txt
baz.txt
#v-
creating 3 folds, 3 elements each. With re=2 it creates a single fold 
containing all the lines.

-- 
Lech Lorens

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui