tlegutko tlegutko - 1 year ago 57
Groovy Question

Vim wrong syntax highlighting in Groovy

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:

enter image description here

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.

Answer Source


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


And around line 260-261 there is

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

Just change the start to


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