Ok.. partially working. I tried the following
set foldmethod=expr strlen(matchstr(getline(v:lnum),'^-*\\ze\\s')) but it only seems to match the single line. It doesn't fold any of the text below that line unless it is a lower level heading. How do I get it to fold the text below the heading. That matched the first 3 folds. After that it doesn't seem to recognize the pattern anymore as On Tue, Nov 11, 2008 at 9:22 AM, Tim Chase <[EMAIL PROTECTED]> wrote: > >>> To fold based on that definition, you can use >>> >>> :set foldmethod=expr >>> :set foldexpr=strlen(matchstr(getline(v:lnum),'^-*')) >> >> Shouldn't the pattern be: '^--*' > > It shouldn't matter much one way or the other. It simply returns > a value of "0" (a perfectly valid value for the foldlevel) if > there aren't any leading "-"s. The expression simply returns > "how many leading dashes are there on the current line?" as the > fold-level -- if that's zero, then it's zero. :) > > > If, as the OP later clarified, you want a trailing space, to > prevent the strlen from getting the wrong-sized input, you can use > > strlen(matchstr(getline(v:lnum),'^-*\\ze\\s')) > > which will ensure that there's a space after the dashes (and not > fold it if there isn't). You could, if you want to be explicit, > change it to '^--*' or '^-\\+' to ensure that there's at least > one dash. However, because foldexpr accepts "0" as a valid > value, I wouldn't go to the trouble. > > -tim > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
