Peng Yu wrote:
Hi,
I'm writing some xml code in vim. In xml, there are some pair like <g>
</g>. Would you please let me know how to pair them as "{" and "}"
such that I can us % to visit them?
Thanks,
Peng
- Install and use the matchit plugin (e.g., add a file
"$VIM/vimfiles/plugin/matchit.vim" with the single line
runtime macros/matchit.vim
)
- I don't know how the xml.vim ftplugin does it; but HTML has similar
paired tags, and my HTML files have the b:match_words variable set to
'<:>,<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,<\@<=\([^/][^
\t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' (I don't do it, ftplugin/html.vim does it).
This pairs < with >, most <tag>s with the corresponding </tag>, and <ol>
or <ul> with any number of <li> with </ol> or </ul> (the cursor jumps
from < to > or vice-versa when on < or >, from the openiung tag to the
closing tag when on the tag name itself).
Best regards,
Tony.