On 14/03/10 19:13, Bill Hudacek wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi, all.  I've been using VIM since v3 but have not had any problems
with it for ..... a few /years/ now :-)

I use VIM to edit XML, and some of these files are huge - the
combination of folding and matchit's '%' mappings really make vim a
great XML editor/viewer.

In a shell script file, '%' works (e.g., if->then->else), but not in
HTML/XML files.  Pressing '%' does nothing.

Vim on this box is Vi IMproved 7.2 (2008 Aug 9, compiled Mar 19 2009
15:27:51).  The version of matchit on this box is 1.13.2.

The following symlinks exist:

/home/bgh/.vim/doc/matchit.txt ->
        /usr/share/vim/addons/doc/matchit.txt

/home/bgh/.vim/plugin/matchit.vim ->
        /usr/share/vim/addons/plugin/matchit.vim

In vim, ":map %" shows this:

o  %           * v:<C-U>call<SNR>15_Match_wrapper('',1,'o')<CR>
v  %           * :<C-U>call<SNR>15_Match_wrapper('',1,'v')<CR>m'gv``
n  %           * :<C-U>call<SNR>15_Match_wrapper('',1,'n')<CR>

When I'm editing an XML file, and I try this:

let b:match_debug=100

...then press '%' on an XML element with children&  a close tag later
in the file, the variable 'b:match_pat' suddenly gets a value:

(:),{:},\[:\],\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>

I have an Ubuntu 8.04 system with Vim 7.1, and matchit v1.11, and it
works for HTML and XML files.

while, on the 8.04 system, it looks far richer:

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

(all on one line)

Does anyone have any idea why matchit won't work in *ML for me?

Or, guidance on how to debug? Matchit seems to be installed correctly,
and reports no errors.

When debug is turned on, I get screenfuls of trace info on both the
8.04 system and the 9.04 system, but I don't know how to redirect or
capture it aside from painful mouse highlighting (of screen after
screen of data...not fun).

TIA - this is one I'd really like to solve.

/Bill

I'm surprised that there hasn't been a reply yet.

For matchit to work, it must be installed (if it is, it will appear in the output of :scriptnames); you also need a b:match_words variable appropriate for the current file. This is normally set by the ftplugin for that filetype (i.e. in these cases, by $VIMRUNTIME/ftplugin/html.vim or by $VIMRUNTIME/ftplugin/xml.vim). To "catch" cases where the ftplugin doesn't yet know about matchit, I have found the following useful:

        :au VimEnter * au FileType * if !exists('b:match_words')
                \ | let b:match_words = &matchpairs | endif

In Vim 7.2.416 (running on openSUSE Linux 11.2, but that oughtn't to make a difference), here's the value (all on one line) of my b:match_words for HTML. (I haven't tried XML, but it could conceivably be different, since the ftplugin is not the same):

<:>,<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,<\@<=\([^/][^ \t>]*
\)[^>]*\%(>\|$\):<\@<=/\1>

That's in a HTML file which has the following first line:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The matchit version is 1.13.2, and has apparently not changed since before Vim 7 even existed; the ftplugin/html.vim is dated 20 Jan 2009, its "matchit-aware" section starts at line 68.


Best regards,
Tony.
--
If this fortune didn't exist, somebody would have invented it.

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

Reply via email to