From dcdb904d97d328b0d71f03e6e0cc645956cf57fa Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Mon, 21 Apr 2008 01:59:48 -0500 Subject: look for the label for a theorem, etc on following lines if it's not on the same line --- vimrc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/vimrc b/vimrc index 47aa533..6cee219 100644 --- a/vimrc +++ b/vimrc @@ -183,10 +183,24 @@ function Latex_foldtext() let line = getline(v:foldstart) " if we get the start of a theorem, format the display nicely - " XXX: allow the label to be on the following line - let matches = matchlist(line, '\\begin{\([^}]*\)}.*\\label{\([^}]*\)}') + let matches = matchlist(line, '\\begin{\([^}]*\)}') if !empty(matches) && has_key(s:latex_types, matches[1]) - return Base_foldtext(s:latex_types[matches[1]] . ": " . matches[2]) + let type = s:latex_types[matches[1]] + let label = '' + let linenum = v:foldstart - 1 + while linenum <= v:foldend + let linenum += 1 + let line = getline(linenum) + let matches = matchlist(line, '\\label{\([^}]*\)}') + if !empty(matches) + let label = matches[1] + break + endif + endwhile + if label != '' + let label = ": " . label + endif + return Base_foldtext(type . label) endif return Base_foldtext() -- cgit v1.2.3