Loading ...
Sorry, an error occurred while loading the content.

syntax region question

Expand Messages
  • Mike Williams
    Hi, Here is a little puzzler for a wet Thursday afternoon (well at least for this longitude and lattitude). The following is a little sample file for
    Message 1 of 1 , May 1, 2003
    • 0 Attachment
      Hi,

      Here is a little puzzler for a wet Thursday afternoon
      (well at least for this longitude and lattitude).

      The following is a little sample file for highlighting
      a region of a file. The region has different start and
      end patterns which can be spread over a number of lines.
      The aim is to have the start and end patterns highlighted
      differently to the rest of the region. The obvious
      solution was to use matchgroup but this did not work for
      me (VIM62b). My solution is keepend with contains= with
      a pattern for the start and end pattern. Is this the
      right solution? Shouldn't they be functionally equivalent?

      Copy the following to a file and then source it. Ignore
      the warnings, they are not important. Comment out the first
      region line and uncomment the second and re-source the file.
      You should see the last line of "plain text" in bold and
      the end pattern for the "5 lines" in plain text.

      --------------------------8<--------------------------
      syn match egDelim contained "A\(C\s*\n\)*B"
      syn match egDelim contained "B\(C\s*\n\)*A"
      " Following line does what I want
      syn region egExample keepend start="A\(C\s*\n\)*B"
      end="B\(C\s*\n\)*A" contains=egDelim
      " Following line does not do what I expect
      "syn region egExample matchgroup=egDelim start="A\(C\s*\n\)*B"
      end="B\(C\s*\n\)*A"
      highlight egDelim gui=italic term=italic
      highlight egExample gui=bold term=bold

      plain text

      AB 1 line BA

      plain text

      AC
      C
      B 5 lines BC
      C
      A

      plain text
      --------------------------8<--------------------------

      Any explanations most welcome.

      TTFN

      Mike
      --
      Age and treachery will beat youth and skill every time.
    Your message has been successfully submitted and would be delivered to recipients shortly.