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

Overriding syntax keyword

Expand Messages
  • Ali
    Hi guys, is there anyway to override a syntax keyword definitions with with a syntax match definition? I know the documentation explicitly states that the
    Message 1 of 4 , Jan 2, 2008
      Hi guys, is there anyway to override a syntax keyword definitions with
      with a syntax match definition?
      I know the documentation explicitly states that the reverse always
      holds, but I have a need to swap the priority.
      So to illustrate in a c program:

      using namespace std;
      int main()
      {
      return 0;
      }

      I would like to replace the syntax for "using namespace std" to
      something else in this manner:
      :syntax match cCommentError ".*\%1l"

      Thanks!
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Charles E Campbell Jr
      ... Keywords provide speedy recognition and are done via hashing. Matches are done with regular expressions, and are nowhere near as speedy. To reverse the
      Message 2 of 4 , Jan 3, 2008
        A.Politz wrote:

        >Ali wrote:
        >
        >
        >
        >>Hi guys, is there anyway to override a syntax keyword definitions with
        >>with a syntax match definition?
        >>I know the documentation explicitly states that the reverse always
        >>holds, but I have a need to swap the priority.
        >>So to illustrate in a c program:
        >>
        >>using namespace std;
        >>int main()
        >>{
        >> return 0;
        >>}
        >>
        >>I would like to replace the syntax for "using namespace std" to
        >>something else in this manner:
        >>:syntax match cCommentError ".*\%1l"
        >>
        >>Thanks!
        >>
        >>
        >>
        >>
        >>
        >>
        >I am no expert when it comes to syntaxstuff. But I believe
        >it is not easily possible. Two things come to my mine.
        >
        >1. Copy the syntax file to your ~/.vim and convert all
        > keywords to syn-match items. Then the other rules about
        > priorities apply.
        >2. Use the match command or matchadd() function instead.
        > These are always preceding the syntax stuff.
        >
        >
        Keywords provide speedy recognition and are done via hashing. Matches
        are done with regular expressions, and are nowhere near as speedy. To
        reverse the effective priority that keywords have over matches:

        syn match AMatch "\K\k*" contains=SomeKeywords
        syn match SomeKeywords contained ...keyword list here...

        Thus one doesn't need to bend all the keywords into separate matches.
        This effectively makes keywords partake in the same priority level as
        other matches while retaining some speediness.

        Happy New Year,
        Chip Campbell


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • A.Politz
        ... I am no expert when it comes to syntaxstuff. But I believe it is not easily possible. Two things come to my mine. 1. Copy the syntax file to your ~/.vim
        Message 3 of 4 , Jan 3, 2008
          Ali wrote:

          >Hi guys, is there anyway to override a syntax keyword definitions with
          >with a syntax match definition?
          >I know the documentation explicitly states that the reverse always
          >holds, but I have a need to swap the priority.
          >So to illustrate in a c program:
          >
          >using namespace std;
          >int main()
          >{
          > return 0;
          >}
          >
          >I would like to replace the syntax for "using namespace std" to
          >something else in this manner:
          >:syntax match cCommentError ".*\%1l"
          >
          >Thanks!
          >>
          >
          >
          I am no expert when it comes to syntaxstuff. But I believe
          it is not easily possible. Two things come to my mine.

          1. Copy the syntax file to your ~/.vim and convert all
          keywords to syn-match items. Then the other rules about
          priorities apply.
          2. Use the match command or matchadd() function instead.
          These are always preceding the syntax stuff.


          -ap

          --
          Ich hab geträumt, der Krieg wär vorbei.


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • A.Politz
          ... And by preceding I mean the opposite. -ap -- Ich hab geträumt, der Krieg wär vorbei. --~--~---------~--~----~------------~-------~--~----~ You received
          Message 4 of 4 , Jan 3, 2008
            A.Politz wrote:

            >Ali wrote:
            >
            >
            >
            >>Hi guys, is there anyway to override a syntax keyword definitions with
            >>with a syntax match definition?
            >>I know the documentation explicitly states that the reverse always
            >>holds, but I have a need to swap the priority.
            >>So to illustrate in a c program:
            >>
            >>using namespace std;
            >>int main()
            >>{
            >> return 0;
            >>}
            >>
            >>I would like to replace the syntax for "using namespace std" to
            >>something else in this manner:
            >>:syntax match cCommentError ".*\%1l"
            >>
            >>Thanks!
            >>
            >>
            >>
            >>
            >>
            >>
            >I am no expert when it comes to syntaxstuff. But I believe
            >it is not easily possible. Two things come to my mine.
            >
            >1. Copy the syntax file to your ~/.vim and convert all
            > keywords to syn-match items. Then the other rules about
            > priorities apply.
            >2. Use the match command or matchadd() function instead.
            > These are always preceding the syntax stuff.
            >
            >
            >-ap
            >
            >
            >
            And by 'preceding' I mean the opposite.

            -ap

            --
            Ich hab geträumt, der Krieg wär vorbei.


            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.