From f20e602980b7e58b64cf4a14e32697fb177213aa Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Mon, 21 Apr 2008 21:53:51 -0500 Subject: generalize the enumerate folding to other list environments --- vimrc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 2e414ee..b9556b2 100644 --- a/vimrc +++ b/vimrc @@ -271,36 +271,44 @@ function Latex_foldtext() " {{{ return Base_foldtext(type . label) endif " }}} - " format enumeration items nicely {{{ + " format list items nicely {{{ let matches = matchlist(line, '\\item\%(\[\(.*\)\]\)\?') if !empty(matches) let item_name = [] let item_index = 0 let nesting = 0 + let type = '' for linenum in range(v:foldstart - 1, 0, -1) let line = getline(linenum) if line =~ '\\item' if nesting == 0 let item_index += 1 endif - elseif line =~ '\\begin{enumeration}' + elseif line =~ '\\begin{document}' + break + elseif line =~ '\\begin' if nesting > 0 let nesting -= 1 else + let new_type = matchstr(line, '\\begin{\zs[^}]*\ze}') + if type == '' + let type = new_type + elseif type != new_type + break + endif let item_name += [item_index] let item_index = -1 endif - elseif line =~ '\\end{enumeration}' + elseif line =~ '\\end' let nesting += 1 - elseif line =~ '\\begin{document}' - break endif endfor let item_name = reverse(item_name) for i in range(len(item_name)) let item_name[i] = s:enumeration(i, item_name[i]) endfor - let line = 'Item: ' . join(item_name, '.') + let type = toupper(strpart(type, 0, 1)) . strpart(type, 1) + let line = type . ': ' . join(item_name, '.') if matches[1] != '' let line .= ' [' . matches[1] . ']' endif -- cgit v1.2.3-54-g00ecf