Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create multi-file template in PhpStorm (or WebStorm)?

I need 2 files for creating new component in React:

${NAME}.js

import React from 'react';
import css from './${NAME}.css';
const ${NAME} = () => (
  <div></div>
);
export default ${NAME};

${NAME}.css

/* Empty */

Note: ${NAME} needs to be entered like constant while creating these files.

I would like to use PhpStorm (or WebStorm) file template feature (or some other simple way) to create both files - by only clicking to create component like on image below:

Example

Is something like that possible ?

like image 556
Jurosh Avatar asked Nov 10 '16 19:11

Jurosh


People also ask

How do I make multiple files in IntelliJ?

To use the new template, right-click a directory in the Project tool window or press Alt+Insert and select the Java MVC template. Specify a name for the model class and IntelliJ IDEA will create all three files.

How do I use live template in WebStorm?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Live Templates. Select the template group where you want to create a new live template (for example, other). If you do not select a template group, the live template will be added to the user group. and select Live Template.

How do I create a project template in IntelliJ?

Create a project from a templateClick New Project on the Welcome screen or select File | New Project from the main menu. In the dialog that opens, click the required template in the Templates section on the left.


1 Answers

As far as I'm aware it's not possible right now unless you code a plugin for that yourself.

https://youtrack.jetbrains.com/issue/IDEA-91565 -- watch this ticket (star/vote/comment) to get notified on any progress.

UPDATE 2020-12-04: The aforementioned ticket has been fixed and multi-file templates are available since 2020.3 version.


Some links if you are thinking about coding it yourself:

  • IntelliJ Platform SDK / Plugin Development Docs
  • API Forum
  • Some example
like image 91
LazyOne Avatar answered Sep 28 '22 16:09

LazyOne