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

highlighting rules for XML

Expand Messages
  • Fabien Meghazi
    Hi all, I would like to add to rules in my vimrc but I don t know how to do this : EG: I would like all xmlTagName books to be highlighted in a different
    Message 1 of 2 , Oct 2, 2007
    • 0 Attachment
      Hi all,

      I would like to add to rules in my vimrc but I don't know how to do this :

      EG:

      I would like all xmlTagName "books" to be highlighted in a different
      way than other tags
      I would like all xmlAttrib "name" to be highlighted in a different way
      than other attributes.

      I know that I should use syn match , syn cluster , hi link, etc.. but
      I don't understand how to use them.

      I tried to understand syntax/html.vim and :he syn but my brain must be
      too small for that.

      Does someone knows a document or something explaining vim hililghting
      rules for human reading ?

      --
      Fabien Meghazi

      Website: http://www.amigrave.com
      Email: agr@...
      IM: amigrave@...

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... For this, you should add syntax rules in (on Unix) ~/.vim/after/syntax/xml.vim or (on Windows and most other systems) ~/vimfiles/after/syntax/xml.vim
      Message 2 of 2 , Oct 2, 2007
      • 0 Attachment
        Fabien Meghazi wrote:
        > Hi all,
        >
        > I would like to add to rules in my vimrc but I don't know how to do this :
        >
        > EG:
        >
        > I would like all xmlTagName "books" to be highlighted in a different
        > way than other tags
        > I would like all xmlAttrib "name" to be highlighted in a different way
        > than other attributes.

        For this, you should add syntax rules in (on Unix) ~/.vim/after/syntax/xml.vim
        or (on Windows and most other systems) ~/vimfiles/after/syntax/xml.vim (Create
        the file if it doesn't exist, as well as any not-yet-existing directories.)

        >
        > I know that I should use syn match , syn cluster , hi link, etc.. but
        > I don't understand how to use them.

        (untested)

        sy keyword xmlTagNameBooks books containedin=xmlTagName
        sy match xmlAttribName /\<name=/ containedin=xmlAttrib
        hi default link xmlTagNameBooks xmlTagName
        hi default link xmlAttribName xmlAttrib

        then add different ":hi" statements for xmlTagNameBooks and xmlAttribName in
        your favourite home-brewed colourscheme (or in your vimrc if you don't have one).

        >
        > I tried to understand syntax/html.vim and :he syn but my brain must be
        > too small for that.
        >
        > Does someone knows a document or something explaining vim hililghting
        > rules for human reading ?
        >

        :help syntax.txt

        Read it slowly with a full coffeepot at hand when you have all your time, no
        headache, no babble-spouting television, and no children running around you
        playing cat-and-mouse. It may help to compare with
        $VIMRUNTIME/syntax/<something>.vim where <something> is a not-too-complex
        language well known to you.


        Best regards,
        Tony.
        --
        Polymer physicists are into chains.

        --~--~---------~--~----~------------~-------~--~----~
        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.