Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

IntelliJ shortcut for Thymeleaf parser-level comment blocks

In Thymeleaf you can use parser-level comment blocks that everything between <!--/* and */--> will be removed by Thymeleaf.

<!--/* This code will be removed at Thymeleaf parsing time! */-->

Is there any way to define this type of comment and use a shortcut for it in the IntelliJ IDEA? I know we can use CTRL + /, but it generates Standard HTML/XML comments which are closed within <!-- and -->.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well, It seems that there are no way to define a new comment style in IntelliJ IDEA. But I found a workaround by using the Live Template functionality.

You can create a live template for parser-level comment blocks and then invoke it. Follow the following path:

File -> Settings -> Editor -> Live Templates -> HTML/XML -> ADD

Copy and paste the following live-template to the Template text, and choose suitable abbreviation and description:

<!--/* $SELECTION$ */-->

enter image description here

There are two ways to use this live template

  1. Type PC and then press the Tab, IntelliJ automatically creates a parser-level comment block.

  2. Mark-up the desired codes or texts and then press Ctrl + Alt + J, and then from the shown pop-up menu you can select the parser-level comment block option.

enter image description here

Unfortunately you cannot set any Keymaps (shortcuts) for your Live-Templates.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...