I can't seem to find a solution to having multiple cursor points in live templates in intellij IDEA
There is not a way to do have the cursor end at multiple points. But you can repeat the same variable in multiple places in your template, Then as you edit that variable, it changes in all the locations.
For example, this simple example will create three variables of the same type, the type of which I enter/edit after I expand the template. The actual template is below. You can copy it to your clipboard and then paste it as a template in the Live Template settings dialog. In the example, I used a variable named EDIT.
<template name="meex" value="$EDIT$ a; $EDIT$ b; $EDIT$ c;" description="Multiple Edit Example" toReformat="true" toShortenFQNames="true">
<variable name="EDIT" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
To answer the OP's question in the comment...
To use the example template:
meex
(or whatever abbreviation you set in step 4A) and then hitting Tab
(or whatever Key was defined in Step 4B).$EDIT$
placeholder variable, and hit Enter when done.You can learn more about Live Templates in the IntelliJ IDEA help documentation here: https://www.jetbrains.com/help/idea/live-templates.html The best way to learn about them is to look at included templates, make a copy of them (Just right click one, select copy, then paste it elsewhere) and then edit the template and look at how the variables are configured in the "Edit variables" button on the template settings dialog. You probably do not want to edit the included templates directly so you do not corrupt them. And before playing around, you may want to back them up, just in case. Exporting them is the easiest way. See the "Sharing live templates through export/import" section at https://www.jetbrains.com/help/idea/sharing-live-templates.html
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