So in a normal Ruby file, if and end are paired into a syntax group, and the syntax group is leveraged for matchit pairing. Creating a syntax group isn't possible with HTML in the middle so that feature is disabled in ERB files. It would be probably possible to mitigate this by adding a look-behind to the \<if\> regexp. I am not likely to attempt this personally.