简体   繁体   中英

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

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 eg ~/.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)

You must create a own JSP File Type eg "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 eg *.jjj .

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

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.

编辑文件类型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM