56

I like intellij's code/file templates, they are working really well for me for single files but it would be great to be able to create multiple files/classes at once.

I did find this question but since it has been a few years since I was hoping that things might have changed.

We are using the mvp pattern in our application so every time we want to create a new view, it requires two classes and two interfaces, which are always in the same pattern. It would be awesome if we could generate all of the infrastructure for this and link up the classes.

Any suggestions or new information would be appreciated? Maybe it is time to log a feature request with JetBrains?

Community
  • 1
  • 1
Trevor Gowing
  • 2,236
  • 22
  • 25
  • 4
    Feature request http://youtrack.jetbrains.com/issue/OC-5351 – Trevor Gowing Aug 08 '13 at 13:27
  • tons of classes make me think of struts... may be you can write a tool to generate multi files, and may be a mvp2 with less class files will appears to replace it. – mysh Jul 17 '15 at 15:26
  • 1
    This feature has finally been developed and is scheduled for release in the 2020.3 EAP. https://youtrack.jetbrains.com/issue/IDEA-91565 – Trevor Gowing Oct 22 '20 at 14:27

5 Answers5

8

This feature seems to be available in ReSharper (another JetBrains IDE). It still does not seem possible in IDEA yet.

leeor
  • 17,041
  • 6
  • 34
  • 60
2

At the moment IDE doesn't support this feature. Most popular youtrack request have 60+ votes, but it still opened(since 2012). You can use 3rd party solution, for example this plugin.

CeH9
  • 372
  • 5
  • 11
1

It's possible (now). See below links.

https://riggaroo.co.za/custom-file-template-group-android-studiointellij/ https://medium.com/codequest/file-group-templates-in-android-studio-unofficial-guide-85dfa0a0c1ec

Jamol
  • 2,281
  • 2
  • 28
  • 28
0

You could easily do that using JavaParser but I am not sure how you could invoke it from the IDEA interface

Federico Tomassetti
  • 2,100
  • 1
  • 19
  • 26
-2

I think you are looking for this,

Open the desired file in the editor. On the main menu, choose Tools | Save File as Template. In the File and Code Templates dialog box that opens specify the new template name and edit the source code, if necessary.save changes and close the dialog box.