Use this page to discuss script 39 matchit: extended % matching

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on
  • This page may be out of date: check the script's page above, and its release notes.

This appears to be the same plugin which is distributed with the official Vim runtime, in $VIMRUNTIME/macros/matchit.vim. See :help matchit-install.

Comments[edit source]

It is very useful when editing a html file use vim to speed up the production efficiency.

Bug[edit source]

Vim 6.3.82 is working fine, but Vim 7.0.237 couldn't work if not manually type in/source let b:match_words=...

Vim 7.0.237 is really old (though not quite as old as 6.3.82). Try upgrading. Vims 7.1, 7.2, and 7.3 all work fine with matchit.vim. --Fritzophrenic 15:22, February 21, 2011 (UTC)

Vim 7.3 : Matchit makes pressing % on ( or { or [ or ] or } or ) and other things not work in javascript files and files when there is <script>javascript code()</script>. Plugin is unstable and should not be used.

The first statement here, that matchit.vim breaks (, {, and [ is only partially true. I did just experiment and discovered that by default, pressing % on these has no effect. However, this is not a defect in the plugin itself. This is a misconfiguration of the b:match_words variable, which a simple glance at the help file for matchit.vim would have discovered. Adding the following to an after/ftplugin/html.vim file will "fix" the issue:
let b:match_words .= ',{:},(:),[:]'
Arguably, the default settings ought to contain these values, however I would hardly call the plugin "unstable" and recommend against using it because of something as trivial as this. The plugin is stable and useful enough to be included in the standard Vim installation's runtime. Always consult the help before assuming the behavior of a plugin or a Vim feature is a bug. --Fritzophrenic 14:29, July 1, 2011 (UTC)
I would like to comment on that: It actually works the first time. Given the following HTML including Javascript:
function hello_world () {
  console.log("some text");
You can use '%' once on the '(' in the Javascript, but you cannot go back. Setting <script>let b:match_debug</script> fixes this behvaiour. So it is actually a bug as adding a debug flag fixes this. --User:NickHibma 2016/09/27

Bug[edit source]

Vim 7.0.235 : Ruby's "<stmt> if <expr>" construct is inappropriately matching end statements because of the way it searches backwards. A simple fix might be to require the if to be the first non-whitespace element on the candidate matching line.

Community content is available under CC-BY-SA unless otherwise noted.