what does "enable live templates" mean in "File and Code Templates"?

Answered

Hi,

There is a checkbox "enable live templates" at the bottom-right corner of "File and Code Templates" , what does it mean?

Can I use the live templates in "File and Code Templates" ? What's the grammar?

1
3 comments

The grammar used as for Live templates. But you will need to escape the template using #[[ ... ]]# see Enable Live Templates check-box description at File and Code Templates reference.

0

Andrey Dernov Can you please give an example of how to use this syntax to insert a live template?

If I give an example 'PHP File Header' template - what am I doing wrong?

declare(strict_types=1);

#[[ somefirm-doc-php ]]#
0

@...

Only live template variables (and predefined at that) can be used in file/code templates, e.g.:

public class ${NAME} {
public static void main(String[] args) {

}

#[[$END$]]#

}

But the functionality is actually broken in the latest version of the IDE. We are working on fixing it in https://youtrack.jetbrains.com/issue/IDEA-159930. Feel free to vote for it.

You can also upvote https://youtrack.jetbrains.com/issue/IDEA-161937 and related issues to have the live+file template functionality extended.

0

Please sign in to leave a comment.