IntelliJ community edition JSP Syntax highlighting

前端 未结 3 1648
花落未央
花落未央 2021-02-13 15:48

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

相关标签:
3条回答
  • 2021-02-13 16:15

    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.

    0 讨论(0)
  • 2021-02-13 16:28

    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.

    0 讨论(0)
  • 2021-02-13 16:30

    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)

    0 讨论(0)
提交回复
热议问题