2 minute read Published:

Groovy Syntax Highlight Update for Vim

The Groovy syntax highlighting that come with the Vim installation has a few thing that I don’t care for. As I transition more away from Eclipse as my main¬†development¬†environment, I’ll spend more time trying to get Vim setup to support more efficient¬†development. Below I’ve¬†enumerated¬†what changes I made to the syntax file and why.


Bold, yellow¬†highlighting¬†of TODO and FIXME tags. I’m not a big fan of¬†blaring¬†reminders. It’s also not good to rely on just stumbling on a TODO as a way of indicating work to be done. If you really going “todo” it, go ahead and make sure you do more than make a tag for the next sap to come along. He might not have TODO and FIXME highlighted in his editor and might not notice your rushed programming.

Why Should def Be Any Different:

def declares a type in Groovy. Similar to Integer, int, String, Array, etc. The word didn’t come up as highlighted and was getting lost when skimming code.

Important Variable Obscured by Greedy RexEx

The match regex used for matching import statements was too greedy. It would highlight parts of the variables that had the word, import, in the name (e.g. importFileFromURL or someimportantmethod).

GStrings Deserve the Same Respect as String"""

The most common use in my code for GStrings is when I am lazily slapping xml into a test and want to be able to still read it and add variable replacement. The original Syntax file was only recognizing the first line of a GString.

The regex for matching import¬†statements was taken from a Java syntax file. The GString update was from¬†Tobias Rapp version¬†0.1.11¬†of the Groovy syntax file. I’ll maintain my version of the file on github¬†with the¬†caveat¬†that some of the changes are skewed to my preferences and that I might add more. Hopefully, the README file will be kept up-to-date.