I have folding enabled to fold code when I edit a file. However I would
like to also be able
to view specific lines (via the option +<num> on the command line.)
Can you write code to detect this option and not fold the code ?
You omit some important details:
1) what is your foldmethod? (":set foldmethod?") If it's
anything other than "manual", there's no easy recourse to "not
fold the code", but you can open that fold rather than close it.
2) I presume by "+<num> on the command line", you mean at the
shell's command-line rather than vim's command-line. This only
allows you to jump to *one* particular line number rather than a
plurality of lines.
Making the assumption that you've got some auto-folding going on
where you can't actually delete folds and that you just want to
open a given list of folds, you may want something like this
v7.0-only
for line in [3,14,15,92,653] | exec line.'norm zO' | endfor
Or, if you have pre-7.0, you could do something like
:g/^/if line =~ '^\(3\|14\|15\|92\|653\)$' | exec 'norm zO' |
endfor
That second one also can be modified for opening lines matching
given patterns:
:g/regexp/norm zO
or, if the pattern/line-number doesn't always end up in a fold,
you can protect it with
:g/regexp/if foldlevel(line('.')) > 0 | exec 'norm zO' | endif
You should be able to use some combination of these, and perhaps
a BufLoad event to get your files to open with particular folds
if desired.
-tim