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

Re: match xml element

Expand Messages
  • A. J. Mechelynck
    ... To move the cursor from the starting to the ending tag, use matchit. The XML filetype-plugin should take care of initializing its variable correctly. If
    Message 1 of 11 , Mar 2 1:15 AM
      Ken Perl wrote:
      > what plugin of the matching command '%' could be used to match a xml element?
      >
      > --
      > perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
      > ")'
      >
      >
      >

      To move the cursor from the starting to the ending tag, use matchit. The
      XML filetype-plugin should take care of initializing its variable correctly.

      If you haven't yet enabled matchit, see ":help matchit-install" and/or
      do the following:

      1. Add a file named one of $VIM/vimfiles/plugin/matchit.vim (for
      system-wide use on any platform), $HOME/.vim/plugin/matchit.vim (for
      user-private use on Unix), $HOME/vimfiles/plugin/matchit.vim (for
      user-private use on Windows), or similar places on other platforms. That
      file is a one-liner containing just

      runtime macros/matchit.vim

      2. Copy $VIMRUNTIME/macros/matchit.txt to one of the directories
      $VIM/vimfiles/doc/ $HOME/.vim/doc/ or $HOME/vimfiles/doc/ (in parallel
      to the above) then do ":helptags <dirname>" where <dirname> is the name
      of the directory in question.

      Step 1 enables the plugin itself, step 2 enables its help.


      To highlight in Visual mode from <tag> to </tag> (inclusive): place the
      cursor on the < of <tag> (manually or by searching) then (in Normal mode)

      v/<\/tag>/;/>

      followed by Enter.


      Best regards,
      Tony.
    • Ken Perl
      I tried to download the plugin from http://www.vim.org/scripts/script.php?script_id=39, and follow up your mail to install and enable it, re-launched the vim
      Message 2 of 11 , Mar 2 11:10 PM
        I tried to download the plugin from
        http://www.vim.org/scripts/script.php?script_id=39, and follow up your
        mail to install and enable it, re-launched the vim 6.2 and open a
        schema file ended with ext .xsd, but the '%' doesn't work,
        I have no idea what's wrong.

        On 3/2/06, A. J. Mechelynck <antoine.mechelynck@...> wrote:
        > Ken Perl wrote:
        > > what plugin of the matching command '%' could be used to match a xml element?
        > >
        > > --
        > > perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
        > > ")'
        > >
        > >
        > >
        >
        > To move the cursor from the starting to the ending tag, use matchit. The
        > XML filetype-plugin should take care of initializing its variable correctly.
        >
        > If you haven't yet enabled matchit, see ":help matchit-install" and/or
        > do the following:
        >
        > 1. Add a file named one of $VIM/vimfiles/plugin/matchit.vim (for
        > system-wide use on any platform), $HOME/.vim/plugin/matchit.vim (for
        > user-private use on Unix), $HOME/vimfiles/plugin/matchit.vim (for
        > user-private use on Windows), or similar places on other platforms. That
        > file is a one-liner containing just
        >
        > runtime macros/matchit.vim
        >
        > 2. Copy $VIMRUNTIME/macros/matchit.txt to one of the directories
        > $VIM/vimfiles/doc/ $HOME/.vim/doc/ or $HOME/vimfiles/doc/ (in parallel
        > to the above) then do ":helptags <dirname>" where <dirname> is the name
        > of the directory in question.
        >
        > Step 1 enables the plugin itself, step 2 enables its help.
        >
        >
        > To highlight in Visual mode from <tag> to </tag> (inclusive): place the
        > cursor on the < of <tag> (manually or by searching) then (in Normal mode)
        >
        > v/<\/tag>/;/>
        >
        > followed by Enter.
        >
        >
        > Best regards,
        > Tony.
        >
        >


        --
        perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
        ")'
      • A. J. Mechelynck
        ... You shouldn t have to download it: in modern distributions of Vim (including 6.4 and 7, at least), matchit.vim and matchit.txt are already in your
        Message 3 of 11 , Mar 3 3:32 AM
          Ken Perl wrote:
          > I tried to download the plugin from
          > http://www.vim.org/scripts/script.php?script_id=39, and follow up your
          > mail to install and enable it, re-launched the vim 6.2 and open a
          > schema file ended with ext .xsd, but the '%' doesn't work,
          > I have no idea what's wrong.
          >
          > On 3/2/06, A. J. Mechelynck <antoine.mechelynck@...> wrote:
          >> Ken Perl wrote:
          >>> what plugin of the matching command '%' could be used to match a xml element?
          >>>
          >>> --
          >>> perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
          >>> ")'
          >>>
          >>>
          >>>
          >> To move the cursor from the starting to the ending tag, use matchit. The
          >> XML filetype-plugin should take care of initializing its variable correctly.
          >>
          >> If you haven't yet enabled matchit, see ":help matchit-install" and/or
          >> do the following:
          >>
          >> 1. Add a file named one of $VIM/vimfiles/plugin/matchit.vim (for
          >> system-wide use on any platform), $HOME/.vim/plugin/matchit.vim (for
          >> user-private use on Unix), $HOME/vimfiles/plugin/matchit.vim (for
          >> user-private use on Windows), or similar places on other platforms. That
          >> file is a one-liner containing just
          >>
          >> runtime macros/matchit.vim
          >>
          >> 2. Copy $VIMRUNTIME/macros/matchit.txt to one of the directories
          >> $VIM/vimfiles/doc/ $HOME/.vim/doc/ or $HOME/vimfiles/doc/ (in parallel
          >> to the above) then do ":helptags <dirname>" where <dirname> is the name
          >> of the directory in question.
          >>
          >> Step 1 enables the plugin itself, step 2 enables its help.
          >>
          >>
          >> To highlight in Visual mode from <tag> to </tag> (inclusive): place the
          >> cursor on the < of <tag> (manually or by searching) then (in Normal mode)
          >>
          >> v/<\/tag>/;/>
          >>
          >> followed by Enter.
          >>
          >>
          >> Best regards,
          >> Tony.
          >>
          >>
          >
          >
          > --
          > perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
          > ")'
          >
          >
          >

          You shouldn't have to download it: in "modern" distributions of Vim
          (including 6.4 and 7, at least), matchit.vim and matchit.txt are already
          in your $VIMRUNTIME/macros directory.

          If you're still using Vim 6.2, then IMO you should upgrade. The current
          "stable" version is 6.4.008, and the current "development" version is
          7.0aa ALPHA with a new "snaphot" almost every night. (Tonight's snaphot
          is number 212.)

          For Windows, you can get either or both from my Vim site
          http://users.skynet.be/antoine.mechelynck/vim/

          For all platforms, you can get Vim 6.4 sources as the following archives
          and patches:

          ftp://ftp.vim.org/pub/vim/unix/
          vim-6.4.tar.bz2
          ftp://ftp.vim.org/pub/vim/extra/
          vim-6.4.extra.tar.gz
          vim-6.4.lang.tar.gz
          ftp://ftp.vim.org/pub/vim/patches/
          6.4.001
          6.4.002
          6.4.003
          6.4.004
          6.4.005
          6.4.006
          6.4.007
          6.4.008
          MD5
          README

          These 3 archives and 8 patches make up the full 6.4 sources and runtime
          files for _all_ platforms, not only Unix, notwithstanding the first
          one's name. I recommend downloading all three archives even if you're on
          en_US Unix: that way you will be able to apply all patches without the
          need for any second-guesses, and the patch program won't complain over a
          "file not found". The patches' README gives a one-line summary of every
          patch's /raison d'ĂȘtre/ . New 6.4 patches are announced on the
          vim-announce list, which is broadcast to all other vim.org mailing lists.

          The 7.0 sources are at ftp://ftp.vim.org/pub/vim/unstable/snapshot/
          Each zip archive in that directory contains the full source and runtime
          files for all platforms and languages, as of its creation date.


          Best regards,
          Tony.
        • Benji Fisher
          ... In The Fine Manual (matchit.txt) there is a section with the tag matchit-activate . As it explains, you need to define the b:match_words variable. Either
          Message 4 of 11 , Mar 3 5:52 AM
            On Fri, Mar 03, 2006 at 03:10:15PM +0800, Ken Perl wrote:
            > I tried to download the plugin from
            > http://www.vim.org/scripts/script.php?script_id=39, and follow up your
            > mail to install and enable it, re-launched the vim 6.2 and open a
            > schema file ended with ext .xsd, but the '%' doesn't work,
            > I have no idea what's wrong.

            In The Fine Manual (matchit.txt) there is a section with the tag
            matchit-activate . As it explains, you need to define the b:match_words
            variable. Either you have not enabled filetype plugins in your vimrc
            file or the XML ftplugin included with vim 6.2 did not support
            matchit.vim . More recent versions do. Either way, see

            :help ftplugins

            Here are the relevant lines from vim64/ftplugin/xml.vim :

            " XML: thanks to Johannes Zellner and Akbar Ibrahim
            " - case sensitive
            " - don't match empty tags <fred/>
            " - match <!--, --> style comments (but not --, --)
            " - match <!, > inlined dtd's. This is not perfect, as it
            " gets confused for example by
            " <!ENTITY gt ">">
            if exists("loaded_matchit")
            let b:match_ignorecase=0
            let b:match_words =
            \ '<:>,' .
            \ '<\@<=!\[CDATA\[:]]>,'.
            \ '<\@<=!--:-->,'.
            \ '<\@<=?\k\+:?>,'.
            \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
            \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
            endif

            HTH --Benji Fisher
          • Ken Perl
            I installed a new vim6.4 on windows and added the two lines into $HOME/_vimrc file, runtime macros/matchit.vim runtime ftpplugin/xml.vim after the next startup
            Message 5 of 11 , Mar 3 9:49 PM
              I installed a new vim6.4 on windows and added the two lines into
              $HOME/_vimrc file,
              runtime macros/matchit.vim
              runtime ftpplugin/xml.vim
              after the next startup of vim, the matching is still not working, I
              read the help and didn't find a way to fix this, how to check if my
              config is correct?

              On 3/3/06, Benji Fisher <benji@...> wrote:
              > On Fri, Mar 03, 2006 at 03:10:15PM +0800, Ken Perl wrote:
              > > I tried to download the plugin from
              > > http://www.vim.org/scripts/script.php?script_id=39, and follow up your
              > > mail to install and enable it, re-launched the vim 6.2 and open a
              > > schema file ended with ext .xsd, but the '%' doesn't work,
              > > I have no idea what's wrong.
              >
              > In The Fine Manual (matchit.txt) there is a section with the tag
              > matchit-activate . As it explains, you need to define the b:match_words
              > variable. Either you have not enabled filetype plugins in your vimrc
              > file or the XML ftplugin included with vim 6.2 did not support
              > matchit.vim . More recent versions do. Either way, see
              >
              > :help ftplugins
              >
              > Here are the relevant lines from vim64/ftplugin/xml.vim :
              >
              > " XML: thanks to Johannes Zellner and Akbar Ibrahim
              > " - case sensitive
              > " - don't match empty tags <fred/>
              > " - match <!--, --> style comments (but not --, --)
              > " - match <!, > inlined dtd's. This is not perfect, as it
              > " gets confused for example by
              > " <!ENTITY gt ">">
              > if exists("loaded_matchit")
              > let b:match_ignorecase=0
              > let b:match_words =
              > \ '<:>,' .
              > \ '<\@<=!\[CDATA\[:]]>,'.
              > \ '<\@<=!--:-->,'.
              > \ '<\@<=?\k\+:?>,'.
              > \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'.
              > \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>'
              > endif
              >
              > HTH --Benji Fisher
              >


              --
              perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
              ")'
            • A. J. Mechelynck
              ... [...] There should be only one p in ftplugin. See also :help :scriptnames . And you can type :echo b:match_words (without the quotes of course) while
              Message 6 of 11 , Mar 3 11:10 PM
                Ken Perl wrote:
                > I installed a new vim6.4 on windows and added the two lines into
                > $HOME/_vimrc file,
                > runtime macros/matchit.vim
                > runtime ftpplugin/xml.vim
                > after the next startup of vim, the matching is still not working, I
                > read the help and didn't find a way to fix this, how to check if my
                > config is correct?
                [...]

                There should be only one p in ftplugin.

                See also ":help :scriptnames".

                And you can type ":echo b:match_words" (without the quotes of course)
                while editing an XML file to see if your XML ftplugin has done the
                necessary setup.

                I notice that for some reason the setup is not done (for my HTML files)
                if the HTML ftplugin is sourced before the matchit plugin, which can
                happen if there is an :edit command in the vimrc. The cure is simple:
                use ":e" to reload the file afterwards.


                Best regards,
                Tony.
              • Ken Perl
                ... 2: C: vim vim64 ftplugin xml.vim 3: C: Documents and Settings pc vimfiles plugin matchit.vim echo b:match_words lets me know that I didn t define some
                Message 7 of 11 , Mar 4 5:27 AM
                  :scritnames lets me know that xml.vim and matchit.vim is loaded already.
                  2: C:\vim\vim64\ftplugin\xml.vim
                  3: C:\Documents and Settings\pc\vimfiles\plugin\matchit.vim

                  "echo b:match_words" lets me know that I didn't define some thing
                  which are needed.
                  E121: Undefined variable: b:match_words
                  E15: Invalid expression: b:match_words

                  It is wired that b:match_words is undefined since matchit and xml are
                  loaded already.


                  On 3/4/06, A. J. Mechelynck <antoine.mechelynck@...> wrote:
                  > Ken Perl wrote:
                  > > I installed a new vim6.4 on windows and added the two lines into
                  > > $HOME/_vimrc file,
                  > > runtime macros/matchit.vim
                  > > runtime ftpplugin/xml.vim
                  > > after the next startup of vim, the matching is still not working, I
                  > > read the help and didn't find a way to fix this, how to check if my
                  > > config is correct?
                  > [...]
                  >
                  > There should be only one p in ftplugin.
                  >
                  > See also ":help :scriptnames".
                  >
                  > And you can type ":echo b:match_words" (without the quotes of course)
                  > while editing an XML file to see if your XML ftplugin has done the
                  > necessary setup.
                  >
                  > I notice that for some reason the setup is not done (for my HTML files)
                  > if the HTML ftplugin is sourced before the matchit plugin, which can
                  > happen if there is an :edit command in the vimrc. The cure is simple:
                  > use ":e" to reload the file afterwards.
                  >
                  >
                  > Best regards,
                  > Tony.
                  >
                  >


                  --
                  perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
                  ")'
                • A. J. Mechelynck
                  ... xml.vim was loaded before matchit.vim -- in that case b:match_words doesn t get defined. Check that you have filetype plugin on ( :filetype with no
                  Message 8 of 11 , Mar 4 5:39 AM
                    Ken Perl wrote:
                    > :scritnames lets me know that xml.vim and matchit.vim is loaded already.
                    > 2: C:\vim\vim64\ftplugin\xml.vim
                    > 3: C:\Documents and Settings\pc\vimfiles\plugin\matchit.vim
                    >
                    > "echo b:match_words" lets me know that I didn't define some thing
                    > which are needed.
                    > E121: Undefined variable: b:match_words
                    > E15: Invalid expression: b:match_words
                    >
                    > It is wired that b:match_words is undefined since matchit and xml are
                    > loaded already.
                    >
                    >

                    xml.vim was loaded before matchit.vim -- in that case b:match_words
                    doesn't get defined. Check that you have filetype plugin on (":filetype"
                    with no arguments will tell you) then place the cursor in an xml file
                    and do ":e" (without quotes) to reload the same file. That should define
                    b:match_words for that file.


                    Best regards,
                    Tony.
                  • Benji Fisher
                    Try adding these two lines you your vimrc file: runtime macros/matchit.vim filetype plugin on If you are bothered by ftplugins for other file types, you can do
                    Message 9 of 11 , Mar 4 8:36 AM
                      Try adding these two lines you your vimrc file:

                      runtime macros/matchit.vim
                      filetype plugin on

                      If you are bothered by ftplugins for other file types, you can do
                      something else, but let's start with this.

                      HTH --Benji Fisher

                      On Sat, Mar 04, 2006 at 01:49:50PM +0800, Ken Perl wrote:
                      > I installed a new vim6.4 on windows and added the two lines into
                      > $HOME/_vimrc file,
                      > runtime macros/matchit.vim
                      > runtime ftpplugin/xml.vim
                      > after the next startup of vim, the matching is still not working, I
                      > read the help and didn't find a way to fix this, how to check if my
                      > config is correct?
                    • Ken Perl
                      Thanks, filetype plugin on solved my problem. when I load a xml file, then echo b:match_words, it returns,
                      Message 10 of 11 , Mar 4 6:29 PM
                        Thanks, 'filetype plugin on' solved my problem.
                        when I load a xml file, then echo b:match_words, it returns,

                        <:>,<\@<=!\[CDATA\[:]]>,<\@<=!--:-->,<\@<=?\k\+:?>,<\@<=\([^ \t>/]\+\)\%(\s\+[^>
                        ]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>

                        and '%' works now, without you all help, I can't make this work,
                        appreciate you both.

                        On 3/5/06, Benji Fisher <benji@...> wrote:
                        > Try adding these two lines you your vimrc file:
                        >
                        > runtime macros/matchit.vim
                        > filetype plugin on
                        >
                        > If you are bothered by ftplugins for other file types, you can do
                        > something else, but let's start with this.
                        >
                        > HTH --Benji Fisher
                        >
                        > On Sat, Mar 04, 2006 at 01:49:50PM +0800, Ken Perl wrote:
                        > > I installed a new vim6.4 on windows and added the two lines into
                        > > $HOME/_vimrc file,
                        > > runtime macros/matchit.vim
                        > > runtime ftpplugin/xml.vim
                        > > after the next startup of vim, the matching is still not working, I
                        > > read the help and didn't find a way to fix this, how to check if my
                        > > config is correct?
                        >


                        --
                        perl -e 'print unpack(u,"62V5N\"FME;G\!E<FQ`9VUA:6PN8V]M\"\@``
                        ")'
                      Your message has been successfully submitted and would be delivered to recipients shortly.