Tim's :foldd and :foldo suggestions are actually very good in deed (didn't know about them), especially with the help of tools to create folds and operate commands on them. I would like to suggest you take a look at my foldutil.vim (http://www.vim.org/script.php?script_id=158).
I only learned about folddo(open|closed) in the year or so, and they're handy to have in one's toolbelt. I don't use 'em often, but sometimes they're just the right tool for the job. However, instead of adding scripts, I usually just define such automated folds with :set foldmethod=expr :set foldexpr=getline(v:lnum)=~'regexp' which will fold any lines matching 'regexp' (or change the "=~" to "!~" if you want lines that *don't* match 'regexp'). These can aso be added together, to allow for multiple conditions: :set foldexpr=(getline(v:lnum)=~'rxp1')+(getline(v:lnum)=~'rxp2') which will fold lines matchine either pattern (although I suspect I'd usually just use :set foldexpr=getline(v:lnum)=~'regex1\|regex2'
That is not true, you can have one line folded, however the default value of 'foldminlines' is 1, which means single-line folds are never shown as closed. You can however set this to 0.
My turn to learn something new. :) Thanks! I've noticed the "only two or more lines get folded" but never had the impetus to investigate further to see if a fold could be made for only one line, as folding only one line never made much sense before the context of this thread. -tim