I downloaded the Matchit plugin and used it on my HTML file. Everything worked as it was supposed to until I used it on my list.
<ol>
<li id="link-1"><a href="http://www.reddit.com/">reddit</a></li>
<li id="link-2"><a href="http://www.vim.org/">vim</a></li>
<li id="link-3"><a href="http://www.w3schools.com/">w3schools</a></li>
</ol>
If the cursor is on the first o when I press tab the cursor jumps to the first list item instead of the closing ol. And when I’m on the l of the first list item the cursor jumps to the l of the next list item tag. But if I move the cursor over to the first a of the link tag and hit tab then Matchit works just fine and jumps to the closing tag. Matchit works for all tags but list items? How do I fix this behavior?
For starter, matchit is distributed with Vim without being activated. You don’t need to download it, just follow the instructions at
:help matchit-install.Matchit uses a buffer variable called
b:match_wordsto define pairs of matching tags: open an HTML file and typeecho b:match_words. The value, here, is:If I understand
:help matchitand these patterns correctly, the<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>part is where the “problem” is. Notice that the behaviour is the same for definition lists: instead of jumping to the end tag, matchit jumps to intermediary tags.I’d guess that pasting this in an HTML ftplugin and doing a bit of customizing would solve the problem.
edit
This line seems to completely resolve the issue:
I’ve just removed the two totally unecessary pattern definitions for
<ul|ol>and<dl>, leaving only the basic matches.