>I'm trying to bound a substitution to the legal range of a procedure
>body. This can be either ?^PROCBEGIN\>?,/^PROCEND\>/ or ?^BEGIN\>?,
>First I tried to a single pattern like this:-
>But this isn't quire right 'cos it'll terminate early or late if the
>PROC's don't balance.
is probably the best you can do. Note the semi-colon is used instead of
If you're trying syntax highlighting, then you can use \z1 to catch the
you can't simply get it. Now, with some vimL:
" call Dfunc("ProcZone()")
let line1 = search('^\(PROC\)\=BEGIN\>','bW')
let procpat = substitute(getline("."),'\(PROC\)\=BEGIN\>','\1','')
let line2 = search(procpat.'END\>','W')
let ret = line1.','.line2
" call Dret("ProcZone ".ret)
You can pass some argument and use exe... with it, etc.
It should search backwards for the first matching line in
question (your "\(PROC\)\=BEGIN" line), and then uses the
exec() call the range created by determining which type of
line it's currently sitting on. Thus it will exec() one of
the following on the line it finds:
depending on whether the first line begins with "PROC" or
It does involve hacking your desired command ("#" in this
case) inside the string passed to exec, but at least it
should do what you're hoping to.