Vim在Groovy中错误的语法突出显示 [英] Vim wrong syntax highlighting in Groovy

查看:117
本文介绍了Vim在Groovy中错误的语法突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入一些算术表达式(比如 val1 / val2 )时,我使用单斜杠( / ),我的vim将它视为多行注释( / * )。结果如下:





现在我可以通过在该行末尾输入; / 来关闭它(它会关闭注释) ,但它仍然很烦人,我希望我的vim能够正常运行:)。



我试过使用另一个vim语法高亮显示时髦包,在我的.vimrc中试过:filetype plugin off ,我尝试用我的设置清除vim并重新安装它,问题仍然存在。

解决方案

解决方案: 正如@cfrick指出的, (我的版本:7.4)将'/'视为常规表达式在Groovy中的开始。解决方案是编辑

  /usr/share/vim/vim74/syntax/groovy.vim 

并且在260-261行附近有

  syn region groovyString start ='/ [^ /]'end ='/'contains = groovySpecialChar,groovyRegexChar,groovyELExpr 

只需将开始改为

  start ='/ [^ * /]'

编辑:将regexp中的空格更改为* as @calid在下面的评论中建议



start ='/ [^ /]'



(即增加空格)

现在看起来好多了。另一方面,它现在不会强调以空格开始的正则表达式,但对我来说没关系。至少比它好得多。



这对我找到我的解决方案帮助很大:
在Vim 7.4中的高亮语法


when I do the single slash (/) when typing some arithmetic expression (like val1 / val2), my vim treats it as a comment for multiple lines (/*). The result looks like:

I now I can escape it by typing ;/ at the end of that line (which closes the comment), but it is still annoying and I'd like for my vim to behave properly :).

I've tried using another vim syntax highlighting package for groovy, I've tried :filetype plugin off in my .vimrc, I've tried purging vim with my settings and reinstalling it and the problem is still there.

解决方案

SOLUTION:

As pointed out by @cfrick, vim (my version: 7.4) treats '/' as beginning of regular expression in groovy. The solution is to edit

/usr/share/vim/vim74/syntax/groovy.vim

And around line 260-261 there is

syn region groovyString           start='/[^/]'  end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr

Just change the start to

start='/[^*/]'

Edit: changed space in regexp to * as @calid suggested in comment below

start='/[^ /]'

(that is add the space there.)

And now it looks much better. On the other hand it will now not highlight regexps starting with space, but for me it's okay. At least it's much better than what it was.

This helped mi a lot with finding my solution: Groovy syntax highlighting in Vim 7.4

这篇关于Vim在Groovy中错误的语法突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆