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

[bug?] \zs in regex not working with ":syn match ..."

Expand Messages
  • Dominique Pellé
    Given the fillowing text in a buffer: ABCDEF GHIJKL The following command does not highlight anything ... Nothing is highlighted. I would expect GHI to be
    Message 1 of 3 , Sep 3, 2010
    • 0 Attachment
      Given the fillowing text in a buffer:

      ABCDEF
      GHIJKL

      The following command does not highlight anything
      and I don't see why:

      :syn clear | syn match Error 'DEF\_.\zsGHI'

      Nothing is highlighted. I would expect GHI to be highlighted.

      Is it a bug?

      You can reproduce it with:

      $ (echo ABCDEF; echo GHIJKL) | \
      vim -u NONE -N \
      -c 'syntax on' \
      -c ":syn clear | syn match Error 'DEF\_.\zsGHI'" -

      If I remove \zs (start of match) then text is highlighted as expected:

      :syn clear | syn match Error 'DEF\_.GHI'

      If I use \ze, then text is also highlighted as expected:

      :syn clear | syn match Error 'DEF\_.\zeGHI'

      But somehow it does not work when I try to use \zs.
      I'm using Vim-7.3.3 on Linux x86.

      -- Dominique

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Jürgen Krämer
      Hi, ... there is a note in :help syntax.txt at line 3567 (Vim 7.3.3): - The start of a match cannot be in a line other than where the pattern matched. This
      Message 2 of 3 , Sep 3, 2010
      • 0 Attachment
        Hi,

        Dominique Pellé schrieb:
        > Given the fillowing text in a buffer:
        >
        > ABCDEF
        > GHIJKL
        >
        > The following command does not highlight anything
        > and I don't see why:
        >
        > :syn clear | syn match Error 'DEF\_.\zsGHI'
        >
        > Nothing is highlighted. I would expect GHI to be highlighted.
        >
        > Is it a bug?
        >
        > You can reproduce it with:
        >
        > $ (echo ABCDEF; echo GHIJKL) | \
        > vim -u NONE -N \
        > -c 'syntax on' \
        > -c ":syn clear | syn match Error 'DEF\_.\zsGHI'" -
        >
        > If I remove \zs (start of match) then text is highlighted as expected:
        >
        > :syn clear | syn match Error 'DEF\_.GHI'
        >
        > If I use \ze, then text is also highlighted as expected:
        >
        > :syn clear | syn match Error 'DEF\_.\zeGHI'
        >
        > But somehow it does not work when I try to use \zs.
        > I'm using Vim-7.3.3 on Linux x86.

        there is a note in :help syntax.txt at line 3567 (Vim 7.3.3):

        - The start of a match cannot be in a line other than where the pattern
        matched. This doesn't work: "a\nb"ms=e. You can make the highlighting
        start in another line, this does work: "a\nb"hs=e.

        This seems to talk about the ms-flag, but it might be relevant to your
        case, too.

        Regards,
        Jürgen

        --
        Sometimes I think the surest sign that intelligent life exists elsewhere
        in the universe is that none of it has tried to contact us. (Calvin)

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Ben Fritz
        ... I think I ve used @= and @
        Message 3 of 3 , Sep 7, 2010
        • 0 Attachment
          On Sep 3, 4:51 am, Jürgen Krämer <jottka...@...> wrote:
          >
          > there is a note in :help syntax.txt at line 3567 (Vim 7.3.3):
          >
          >   - The start of a match cannot be in a line other than where the pattern
          >     matched.  This doesn't work: "a\nb"ms=e.  You can make the highlighting
          >     start in another line, this does work: "a\nb"hs=e.
          >
          > This seems to talk about the ms-flag, but it might be relevant to your
          > case, too.
          >

          I think I've used \@= and \@<= before to match previous lines to the
          start of the match. Maybe these will work for you as well?

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.