开发者

Vim: brace matching unreliable

开发者 https://www.devze.com 2023-04-08 10:51 出处:网络
I\'m using Vim to edit JSP files with JavaScript. Somehow the % key (jump to matching brace) doesn\'t work most of the time: Sometimes it works, sometimes it works only in one direction, but most of t

I'm using Vim to edit JSP files with JavaScript. Somehow the % key (jump to matching brace) doesn't work most of the time: Sometimes it works, sometimes it works only in one direction, but most of the time it doesn't work at all. Of course Vim is able to highlight the right matching brace, but matchit.vim doesn't seem to开发者_如何学运维 find it. I'm using the latest version (1.13.2) of the plugin.

Example:

<s:layout-component name="extra_styles">
@import "${mediaPath}/css/whatever.css";
.test .someclassname {
    top: 5px;
    left: 32px;
}
</s:layout-component>

Here it won't find the matching curly brace.

Does anyone know a solution for this?


I had the same problem: % wouldn't jump to matching {}. This is my workaround:

:let b:match_debug=1

% starts dancing after that.

Hope it helps.


I think it has something to do with the JSP syntax definition: I changed the filetype on your example to css: matchit jumps correctly from one curly brace to the other. Changing the filetype back to jsp makes matchit all dizzy.

:set ft=css.jsp seems to allow both the correct matchit behaviour and CSS omni-completion. See if it doesn't break anything on the jsp front.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号