1

I want to create syntax highlighting for indentation sensitive language that I'm designing, my question is how to highlight multiline comment that begins with #!
something like this

#! xxxxxxxxxxx
 xxxxxxxxx
    xxxxxxxxx
 xxxxxx
    xxxxxx

or

func arg1 arg2 #! xxxxxxxxxxx
                 xxxxxxxxx
                xxxxxxxxx
                xxxxxx
                  xxxxxx
  arg3
  arg4

Edit
I found a solution for the first example

syn match CommentBlock /\( *\)#!.*\n\(\1 .*\n\)*/
  • 4
    What identifies the end of the comment? – Steve Aug 17 '16 at 7:41
  • if the next line after #! have a shorter indentation from where #! is located it then identified as the end of the comment – raoof Aug 17 '16 at 9:48
  • Your example would then make identifying the comment difficult as #! has no indentation. Does the comment end at arg3 or the second lot of xxxxxx?\ – Steve Aug 17 '16 at 13:30
  • it ends at arg3, matching the first example ( with indentation for #! ) would be fine – raoof Aug 17 '16 at 14:04
  • See :h syn-region – Tumbler41 Aug 17 '16 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.