Questions tagged [live-templates]

Available in most JetBrains IDEs, live templates let you insert frequently used or custom code constructs into your source code file quickly, efficiently, and accurately. They contain predefined code fragments.

201 questions
101
votes
1 answer

Choose position of cursor after a live template

In IntelliJ IDEA, I have defined a live template like this: @Inject private void postInject() { //I want the cursor to be placed here after the execution of the live template. } Is there a way to tell IntelliJ to place the cursor inside of the…
Arnaud Denoyelle
  • 29,980
  • 16
  • 92
  • 148
88
votes
3 answers

Intellij Live Template

Is there any way to use a default token value in Intellij Live templates? For example I have the following live template which declares a private variable that I would like to create nearly for every class: private static final Logger logger =…
Leonid
  • 22,360
  • 25
  • 67
  • 91
64
votes
3 answers

How To Insert Incrementing Numbers with words by Multicursor in jetbrains IDE(IntelliJ IDEA)?

I want to add Incrementing Numbers with words by Multicursor in jetbrains IDE(IntelliJ IDEA) . Is there any way to do it by Live template? I want to do things like this image :
Shaiful
  • 928
  • 1
  • 10
  • 11
47
votes
6 answers

Auto-generate Android Log TAG in Android Studio/Intellij idea

In Intellij Idea when i typing psfs and then press Ctrl+J IDE was getting me a dialog : And when i press Enter i get an I know where i can customize my own output But i can't any doc's how i can write my own live template. In the end i want to…
Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
44
votes
2 answers

How to set default value of variable in live template in Intellij IDEA?

There could be a little misunterstanding in live templates in Intellij IDEA. I mean default values for variables in templates. Suppose we have this live template What I expect here, that when calling this template (type jqon and press TAB) I will…
Vitalii Korsakov
  • 45,737
  • 20
  • 72
  • 90
31
votes
6 answers

Live Template not working in Kotlin

Hope you have worked with Live Templates which is given by Android by default. Like: Generate debug log statement: "logd"+TAB Generate error log statement: "loge"+TAB Generate info log statement: "logi"+TAB Generate TAG declaration:…
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
29
votes
7 answers

How configure Intellij Idea javadoc templates?

I have some method: public int getSomeField() I want to generate javadoc like this: /** * Gets {someField} * * @return value of {someField} */ Where {someField} is placeholder for field name. It is possible to create this templates for Intellij…
Cherry
  • 31,309
  • 66
  • 224
  • 364
28
votes
1 answer

How to use variable value in live templates in Intellij IDEA?

I want to create live template for setter. I've created this template How can I use value of par variable to generate value of var variable? Basically, I want to avoid redundancy here and put name of variable only once and other one will be…
Vitalii Korsakov
  • 45,737
  • 20
  • 72
  • 90
20
votes
5 answers

How to enter logger definition in IntelliJ fast?

Are there some live template or something, to add logger definition into a class? In Eclipse I had a template: private static final Logger log = LoggerFactory.getLogger(${enclosing_type}.class); Don't see something about this in Log Support plugin.
Dims
  • 47,675
  • 117
  • 331
  • 600
18
votes
3 answers

Live Template fore Intellij IDEA for Iterating through Map

We can iterate through collection easily by pressing Ctrl+Alt+T, And then I wanted to create such template for iterating through map: I wrote these lines to template text box: for (Map.Entry<$ELEMENT_TYPE$> $VAR$ : $SELECTION$.entrySet()) { …
Jama A.
  • 15,680
  • 10
  • 55
  • 88
15
votes
4 answers

What is the Eclipse equivalent of IntelliJ "Live templates"?

I mean stuff like typing "iter" and getting a "for" loop with a choice of what variable to iterate on , typing "soutv" to generate a "System.out.println" with the "variable=" already in ... Thanks !
akapulko2020
  • 1,079
  • 2
  • 22
  • 36
14
votes
2 answers

How can i add custom expression functions for Live templates in Intellij

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…
Aman
  • 916
  • 11
  • 16
13
votes
1 answer

How to capitalize one instance of a variable in a live template?

I am trying to make a template for React useState: const [item, setItem] = useState('value') const [$state$, set$state$] = useState($init$);$end$ Since item is the same, only with a capital I, is it possible to auto-capitalize the first letter? I…
ilyo
  • 35,851
  • 46
  • 106
  • 159
10
votes
1 answer

How can I export specific live templates in Webstorm?

I have some live templates in Webstorm that I would like to share with my team mates. I can see that there is a way to export live templates from WebStorm, however, this just seems to do a blanket export of all live templates to a .jar file. Is…
IngageStroliaC
  • 245
  • 1
  • 3
  • 8
9
votes
0 answers

How to specify import for Live Template with Kotlin extension function in Intellij

I'm using the following Live Template: timber.log.Timber.debug { "$METHOD_NAME$" } where debug is an extension function: package timber.log inline fun Timber.debug(throwable: Throwable? = null, message: () -> String) { log(DEBUG, throwable,…
1
2 3
13 14