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
5
votes
1 answer

Define live templates with the same abbreviation for different contexts

I'd like to define two live templates for PHP and JavaScript with the same abbreviation: t. In Live Templates preferences I have set $this-> for PHP, but I cannot set this in JavaScript because of error Duplicate live templates in user group Is…
hsz
  • 148,279
  • 62
  • 259
  • 315
4
votes
1 answer

Resharper and live templates. Get the list of parameters in a method

I want to create a live template with resharper that allows me to write logging information inserting method name and method parameters, something like this: I have in my code, a method like this: public void searchByParams(String param1, String…
Fernando Moyano
  • 1,097
  • 4
  • 15
  • 29
4
votes
2 answers

Extending class documentation and live templates

I am playing with code documentation and live templates and I quite don't get it. I've read Dr.Bob's article about generating documentation and wiki articles about live templates but I have one problem with class description. By class description I…
Wodzu
  • 6,932
  • 10
  • 65
  • 105
4
votes
2 answers

Intellij Idea wrapping live template

I want to create a live template to wrap a code before the dot. Example: I enter userDao.getUser().asst Press enter Code is wrapped and the result is: assertThat(userDao.getUser()) So basically I want to create a live template with functionality…
4
votes
1 answer

Using custom code snippets (live templates) with a Flutter app in Android Studio

In online tutorials I see people type a few characters that can quickly expand to code snippets. That would save a lot of boilerplate code. How do I do that in Android Studio for Flutter development?
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
4
votes
1 answer

how to config Intellij Idea live template's applicable context?

I want to create a live templates group for my custom file type, but when i pick a applicable context, there are a list of kind of file type or language but my custom file type. Is the list predefined and can not extend?
John Hou
  • 219
  • 2
  • 11
4
votes
2 answers

Current file path in Live Template

Is it possible to get the full path of the current file within a live template in IntelliJ? I've tried using groovyScript("new File('.').absolutePath") function, but that returns /Applications/IntelliJ IDEA.app/Contents/bin/. and not the file path…
Adunahay
  • 1,551
  • 1
  • 13
  • 20
4
votes
1 answer

How to edit template in Android Studio / JetBrains IntelliJ IDEA?

I wonder to add changed "loge" template in the Android Studio editor to remove the last required param - Exception object. How "loge" template result looks now: Before the dafualt template insert: public void doSmth() { //start write "loge" word…
4
votes
1 answer

Auto generate random long in IntelliJ Live Template

How do I auto generate an arbitrary number (Long) for use in a Live Template in IntelliJ? Example: public static final long uid = $randomLong$; where randomLong is replaced with a random long value. I have tried adding the following as an…
travega
  • 8,284
  • 16
  • 63
  • 91
3
votes
1 answer

How to add an autoimport to WebStorm Live Templates

I have a live template useS for const [$VAR1$, set$VAR2$] = useState($END$); where useState is an external variable that has to be imported like so: import { useState } from "react"; Whenever this template is used, the import should be…
henk
  • 2,677
  • 2
  • 18
  • 49
3
votes
0 answers

How to create live template like `condition.if` that natively supported by JetBrains IDE?

In JetBrains IDE including PHPStorm, PyCharm, IntelliJ Idea, I can type this age > 0.if Then press tab and I will get if (age > 0) { } In my application I need to type a lot of these: const resPartnerFactory = new…
tom10271
  • 4,222
  • 5
  • 33
  • 62
3
votes
1 answer

WebStorm live templates: how to create an 'export default from' live template / How to get current folder name?

I am working on React projects, where components have the following file structure: ComponentName/ ├── ComponentName.jsx ├── possiblySomeOtherFiles.js/jsx └── index.js and index.js reexports ComponentName.jsx like so: import ComponentName from…
Michal Kurz
  • 1,592
  • 13
  • 41
3
votes
1 answer

WebStorm Live Template $SELECTION$ Regular Expression

I have figured out that I can use $SELECTION$ as a parameter to live template functions inside the "EDIT VARIABLES" modal. However, it will only work if I invoke it the "Surround with Live Template" hotkey. However, only templates which have…
Croolsby
  • 1,416
  • 1
  • 14
  • 14
3
votes
2 answers

Intellij Idea Live Templates

I faced with the problem of writing my vcs current branch name each time I have written 'todo' comment. Recently I learned about Intellij's 'Live Templates' which is quite comfortable to use. I tried to apply it to my problem but there's no…
Lelay
  • 31
  • 2
3
votes
0 answers

How to reverse the order of input and echoed input in an Android Studio 3.1.2 "Live template"?

I'm in Android Studio 3.1.2's File , Settings... , Editor , Live templates creating a new template named lgg to aid with debugging my problems with Context: Log.w("", "<" + $VAR2$ + "> is value of [$VAR2$]"); Note that $VAR2$ occurs in two…
DSlomer64
  • 4,234
  • 4
  • 53
  • 88
1 2
3
13 14