0

I have this vimscript:

syn region      fdocCommand     start="^@" end="$" contained 
syn region      fdocComment     start="^@" end="^@tangle " contains=fdocCommand keepend
" syn region      fdocComment     start="^@" end="^@felix" contains=fdocCommand keepend

but what i need is the region defined by: start="^@" followed by anything except "tangle" or "felix" and ended by either "@tangle" or "@felix". A weaker form would actually do, either the @tangle line above OR the commented out @felix line.

The actual use is a literate programming tool with @commands like @h1 heading, @title, etc, and code is introduced by @felix or @tangle and ended by the next @command. As it happens my webserver can display this with syntax highlighting and hyperlinking, and the real set of code commands include @python, @ocaml, @c++ etc. For Felix, the @..@felix sequence is actually recognised by the compiler as a comment, so the literate code can be compiled directly.

1 Answer 1

2

To start a region only with @commands that are not @tangle, you need negative lookahead via \@!: ^@\%(tangle\)\@!. To ensure that it's really only tangle, not something starting with tangle, you need an additional $ assertion; and to not match felix, too, another branch: ^@\%(\%(tangle\|felix\)$\)\@!

So, this should do:

syn region      fdocComment     start="^@\%(\%(tangle\|felix\)$\)\@!" end="^@\%(tangle\|felix\)$" contains=fdocCommand keepend
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This seems to work: syn region fdocComment start="^@\%(\%(tangle \|felix))\@!" end="^@\%(tangle \|felix)" contains=fdocCommand keepend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.