Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ community edition JSP Syntax highlighting

I just downloaded IntelliJ 15.0.1 Community Edition because i'm sick of Eclipse and it looks horrible on my laptop (Ubuntu 14.04 LTS). Everything was going pretty well until I saw that syntax highlighting in JSP files was not working.

I went to Settings/Editor/File Types

In the Recognized File Types,among other options, I have this one:

JSP Files (syntax Highlighting Only)

When I select it I can see in the registered patterns: *.jsp, *.tag which is exactly what I want ... but it doesn't work ...any ideas?

Thanks

like image 433
Peter Catalin Avatar asked Nov 18 '15 14:11

Peter Catalin


People also ask

How do I enable syntax highlighting in IntelliJ?

Enable semantic highlighting Press Ctrl+Alt+S to open the IDE settings and select Editor | Color Scheme | Language Defaults | Semantic highlighting. Select the Semantic highlighting checkbox and customize the color ranges if necessary.

Can IntelliJ be used for JSP?

This tutorial describes how to create a simple Java EE web application in IntelliJ IDEA. The application will include a single JSP page that shows Hello, World! and a link to a Java servlet that also shows Hello, World! .

Does IntelliJ Community Edition support JavaScript?

Since the Community Edition of IntelliJ doesn't natively support TypeScript or JavaScript, you may choose to include some available Enterprise plugins or purchase IntelliJ Ultimate.


3 Answers

IntelliJ IDEA allows to manually add syntax highlighting settings in "Settings > File Types" even in the Community Edition BUT it ignores these settings after a restart.

These settings are stored in the user's home directory at e.g. ~/.IdeaIC2016.1/config/filetypes/*.xml. Unfortunately, after a restart of the IDE, these settings are NOT read, therefore it seems useless to configure any settings :-(

<filetype binary="false" description="JSP files (syntax highlighting only)" name="JSP">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="" />
      <option name="COMMENT_START" value="&lt;%--" />
      <option name="COMMENT_END" value="--%&gt;" />
      <option name="HEX_PREFIX" value="#" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="%&gt;;&lt;%!;&lt;%@;include;page;taglib" ignore_case="false" />
    <keywords2 keywords="c:choose;c:if;c:otherwise;c:set;c:url;c:when;fmt:message;fmt:setBundle;fmt:setLocale;s:eval;s:message;sec:authorize" />
    <keywords3 keywords="html;head;title;meta;header;nav;section;footer;body;a;br;hr;div;form;input;button;submit;textarea;p;script;noscript;span;style;table;td;th;tr;ol;ul;li;label;i;h1;h2;h3;h4;h5;img" />
    <keywords4 keywords="if;else;function;for;do;let;this;while;with;thows;true;false;char;case;continue;alert;confirm;console;length;return;var;boolean;forms;" />
  </highlighting>
</filetype>

(~/.IdeaIC2016.1/config/filetypes/JSP.xml )

IntelliJ Community Edition also ignores any file-type settings for CSS-files that could look like this:

<filetype binary="false" description="CSS files (syntax highlighting only)" name="CSS">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="#" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
    </options>
    <keywords keywords="a;body;button;div;font;font-face;form;frame;h1;h2;h3;h4;iframe;img;import;input;li;link;media;nav;ol;option;p;select;span;table;td;th;title;tr;u;ul;video" ignore_case="false" />
    <keywords2 keywords="  box-shadow;background;background-color;border;border-radius;bottom;box-shadow;color;content;cursor;display;float;font-family;font-size;font-weight;height;left;line-height;list-style-type;margin;margin-bottom;margin-left;margin-right;margin-top;outline;overflow;padding;padding-bottom;padding-left;padding-right;padding-top;position;right;text-align;text-decoration;text-transform;top;vertical-align;white-space;width;z-index;zoom" />
    <keywords3 keywords="em;pt;px;rgb;rgba" />
    <keywords4 keywords="!important;active;after;before;hover;none;visited" />
  </highlighting>
</filetype>

(~/.IdeaIC2016.1/config/filetypes/CSS.xml)

like image 60
Roland Avatar answered Oct 05 '22 00:10

Roland


You must create a own JSP File Type e.g. "My JSP". The registered File Patterns must be:

*.j?p

*.j?pf

(*.jsp are reserved)

In the default File Type: "JSP Files (syntax Highlighting Only)" you must delete the File Patterns *.jsp. Set it to e.g. *.jjj.

Then the IntelliJ Idea saves this File Type and after a Restart the Settings are still available.

like image 42
Swerner1975 Avatar answered Oct 05 '22 00:10

Swerner1975


IntelliJ supports JSP syntax highlighting, but strangely none of the syntax is predefined. It allows us to define the syntax though if you double click "JSP Files (syntax highlighting only)".

The + / - buttons below allows to add keywords and 1 / 2 / 3 / 4 tabs give different syntax colours. It is not possible to add all HTML/JSP keywords manually one by one but I've defined most common used keywords and it is much better than having no highlighting at all.

Edit File Type

like image 25
aarjithn Avatar answered Oct 05 '22 00:10

aarjithn