Add generics (<>) highlighting to jEdit

jEdit (, my favorite editor, has extensive support for highlighting dozens of languages. However, the Java highlighting plug-in does not support generics: it does not highlight the words between ‘<' and '>‘. Therefore, I edited the highlighting Java file so it supports this feature.

In Ubuntu, the highlight files are stored inside /usr/share/jedit/modes/. Copy the java.xml to ~/.jedit/modes/, and edit the file. Add the follow code somewhere in the file:

<SEQ_REGEXP TYPE="KEYWORD2" HASH_CHAR="&lt;" AT_WORD_START="FALSE">&lt;(\w|&lt;[\w,\s]*&gt;|\s|,)*&gt;</SEQ_REGEXP>
<SEQ_REGEXP TYPE="FUNCTION" HASH_CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ." AT_WORD_START="TRUE">(?=\.)?\w*(?=&lt;(\w|&lt;[\w,\s]*&gt;|\s|,)*&gt;\()</SEQ_REGEXP>

Save the file and edit the catalog file. Add

<MODE NAME="java-tokens" FILE="java.xml" FILE_NAME_GLOB="*.java" />


Now save the file and start jEdit. Now, the generics inside Java files should be highlighted.

In Windows, the procedure is the same, but the file locations may differ

Tags: , ,

Leave a Reply