2

I'm writing a Syntax file for Robot Framework. I want to create a color scheme for the [Documentation] tag, such that the text following the tag, and all subsequent lines beginning with ... until the next line that does not begin with ... are matched. So for example:

1    Test Case 1
2        [Documentation]  This
3        ...    Is
4        ...    Documentation
5        [Setup]    Run Keywords    Keyword1
6        ...    AND        Keyword2

I want to match lines 2-4, but not 1, 5, or 6. I'm not sure if this is possible, and if so, I have no idea where to start.

2

1 Answer 1

5

This should be possible with a syntax region. If you put the following in your syntax file, it should work:

syntax region Documentation
  \ start=/^\s*\[Documentation\]/
  \ end=/^\s*\[\|^\s*$/me=s-1
highlight link Documentation Comment

The highlight is only for testing to show that it works, and you probably both can and should use a different highlight. At least I think this will provide an example that you can build further upon.

For relevant help, see

  • :h :syn-region
  • :h :syn-pattern (for the me=s-1 part)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.