 <p>Write a Vim function in .vimrc using the <code>searchpair</code> built-in function:</p> <pre><code>searchpair({start}, {middle}, {end} [, {flags} [, {skip} [, {stopline} [, {timeout}]]]]) Search for the match of a nested start-end pair. This can be used to find the "endif" that matches an "if", while other if/endif pairs in between are ignored. [...] </code></pre> <p>(<a href="http://vimdoc.sourceforge.net/htmldoc/eval.html" rel="nofollow noreferrer">http://vimdoc.sourceforge.net/htmldoc/eval.html</a>)</p>