How can add new custom functions for Live Templates in Idea Intellij.
For example i need a custom function which can convert a live template variable from Camel Case to Spaced. i.e in Live Template on variable has to be inserted at multiple places with & without space.
Eg. "MyVar" and "My Var". So i want to insert an expression to convert 'MyVar' to 'My Var'.
No expression available by default can be used for this.
Thanks.
Invoke type-matching completion By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu. If necessary, press Ctrl+Shift+Space once again.
Live Templates reduce the amount of code you need to type for the more common code constructs. You can use psvm or main to create the main Java method, for example. There are lots of live templates including fori for a for i loop and nn for not null, plus many more.
Press Ctrl+Alt+S to open the IDE settings and select Editor | File and Code Templates. and specify the template name, file extension, name of the resulting file, and body of the template. Apply the changes and close the dialog.
There is OpenAPI for providing Live Template functions. One can create IntelliJ IDEA plug-in that will add more functions.
See the Macro abstract class. Plug-in should define extension point, like this one:
<liveTemplateMacro implementation="com.intellij.codeInsight.template.macro.CapitalizeMacro"/>
Search IntelliJ IDEA Community code base for sample implementations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With