> In a shell here-document there is no indication of the script language
> for the embedded document

That's not necessarily true, I've done something similar and highlighted
awk commands as awk from inside a shell script. The trick is that `awk'
usually shows up on the command line so you can match that and make a
guess that the string is an awk script, which works good enough for me.
Using \@<= helps with that from within syn-regions.

For example:
  awk 'BEGIN { print "hello, world" }'

Could be matched with something like:
  syn region shAwk start=+\v(awk.*)@<='+ end=+'+ ...


> The wiki page with the tip also says (at the end) the highlighting does 
> not end where it should, and I happen to run into exactly this bug. :(

I think adding `keepend' to the syntax line might help with this.


> I also have another question: how do I make a syntax region that starts 
> with a possibly-quoted identifier, like:
> 
>       "script"-\delimit'er'
> 
> and ends with the /necessarily/ the same *un-quoted* identifier:
> 
>       script_delimiter
> 
> Is there a way to express this with vim syntax highlighting commands ?

You can use \z(\) and \z1 in a syn-region, but it probably won't support
crazy quotations. I would just recommend not putting crazy quotations in
your here document identifiers.. After all, you probably don't want to
make vim a full-blown bash interpreter.


> Also, I would like to define a new syntax region that is contained in 
> the shHereDoc group (already defined in syntax/sh.vim), and that:
>       - start where the shHereDoc starts, if the shHereDoc starts
>         with the exact text '# vi:ft=sh' as one of the first 4 lines
>       - ends where the shHereDoc ends
> Can I express this with vim syntax highlighting ?

You can do the `first 4 lines part' part using `\ze(\n.*){1,4}PATTERN'.
I'm not sure about the best way to match the start of an existing group
though. I would probably just copy the start= pattern from sh.vim, but
there may be a better way.

syn region shAwk start=+<<\v\z(.*)\ze(\n.*){1,4}vim:.*ft\=awk+ end=+\z1+ ...

Attachment: pgphmPsk03JxS.pgp
Description: PGP signature

Reply via email to