Is it possible to use live-templates as file templates?

谁都会走 提交于 2020-01-02 05:45:26

问题


In the intellij products I'm very fond of the live-templates. I wonder if it is possible to use the same syntax for file templates, e.g. formatting a variable to snake- or camel-camese, defining a starting cursor position and so on.


回答1:


Unfortunately you cannot use the same functions/macros available in Live Templates in File Templates.

File Templates use Apache Velocity template language. It allows some Java(?) simple methods to be run on variables (e.g. #set($class_start = $class.substring(0,1).toUpperCase())). Quite possible that more complex methods will work as well.


UPDATE (2017/01/13):

As of 2016.1 (or perhaps 2016.2) version it's now possible to use some Live Templates in File Templates as well (by checking Enable Live Templates checkbox for that File template). I'm not 100% sure if it will do the requested here thing (not tested myself).

Syntax example: #[[ $MY_VARIABLE$ $END$ ]]#

https://www.jetbrains.com/help/phpstorm/2016.3/file-and-code-templates-2.html



来源:https://stackoverflow.com/questions/26425387/is-it-possible-to-use-live-templates-as-file-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!