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.
VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.
After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.
Vim comes with syntax highlighting for many popular languages, including Python, though it is not always the best one. There are several options to improve the default highlighting.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With