Where do Java templates live in Intellij-IDEA?

No Java

I could not find live templates for Java! Who can tell me how to install? Thanks.

+8
intellij-idea
source share
2 answers

They are located in all nodes that are not specific to a language other than Java: iteration, output, normal, voluminous, etc.

+6
source share

As JB Nizet wrote, there is no special node for Java (but you can create one). If you want to create your own custom template for Java, follow these steps:

  • Open the settings window (File → Settings)

  • Click Editor → Live Templates

  • Select the template group to which you want to add your live template (you can create your own template group if you want)

  • Click the + icon and select Live Template

  • Indicate the text of the abbreviation, description and template.

  • Remember to define the context (in your case Java)

Example

Here is an example of how to create your own TODO text

Open the settings window using the Live Templates editor (as described above).

Click the + icon and select "Template Group."

Name this Java group.

enter image description here

Click the + icon again and select Live Template.

Indicate your Live Template and DEFINE CONTEXT .

enter image description here

In my case, writing mtodo and pressing enter will result in:

// TODO myName 

You can even use variables. Write in the text of the template, for example. $ DATE $ and $ TIME $

 // TODO myName $DATE$ $TIME$ 

Click the "Change Variables" button and assign each variable (defined by the dollar sign) and expression (predefined function).

enter image description here

Now mtodo will lead to

 // TODO myName 13.10.2015 15:39 

Here you can find the predefined functions here . An example was created using IntelliJ IDEA 15 EAP.

+3
source share

All Articles