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

android - groovy script error in custom live template

I am attempting to create a custom live template to bind views in activity_main.xml to MainActivity.java (w/ Butterknife) as global variables with the view's id as the variable name. bindScript.groovy //Arguments to be used in live template def cN =…
flopshot
  • 1,153
  • 1
  • 16
  • 23
3
votes
2 answers

How can I name a variable automatically by its type in a live template?

Using dagger, Im injecting fields a lot - so I created a live template for declaring an injected variable: @Inject lateinit var $var$: $TYPE$ In Java, a similar live template would automatically fill in repository as I specified the type to be…
zoltish
  • 2,122
  • 19
  • 37
3
votes
1 answer

PhpStorm $SELECTION$ in live template does not work

I watched this video: https://www.youtube.com/watch?v=8LXJfYvq8z8 and tried to make a live template for try catch block. try { $SELECTION$ } catch ($TYPE$ $$$VARIABLENAME$) { $END$ } Now I select a code which I want to be surrounded and…
Dariux
  • 3,953
  • 9
  • 43
  • 69
3
votes
1 answer

How can I configure a live template that generates a builder method in IntelliJ IDEA?

I oftentimes need to create builder methods in my code. These methods are similar to getters, but they return this and they use with instead of get. To be faster with that task I'd like to create a live-template in IDEA. This how far I got: (in…
yankee
  • 38,872
  • 15
  • 103
  • 162
3
votes
1 answer

Surround multiple lines with quotes

I'm trying to build a live template that will work like the 'wrap in comment' live template (that puts a // before each selected line). For example, select multiple lines of text, click Code > Surround With > Single quotes (custom live template) and…
Rob Campion
  • 1,359
  • 13
  • 26
3
votes
1 answer

How can I dynamically create a php variable in a PhpStorm live template?

I'm trying to create a live template in PhpStorm but I'm having trouble with dynamically creating variables. I'm trying to do something like this: $$VARIABLE_NAME$ = function($END$) { }; $this->foo(array('$VARIABLE_NAME$' =>…
Rich McCluskey
  • 1,871
  • 2
  • 18
  • 30
3
votes
0 answers

Resharper Live Template Macro that changes variable name upon exit

I would like to create a Resharper Live Template that changes all spaces to underscores ind my "fact" Live template variable $testname$: _ Public Sub $testnames$() ' Arrange $END$ ' Act ' Assert End Sub I have this: …
Luhmann
  • 3,860
  • 26
  • 33
3
votes
0 answers

Live Templates - schema

In Delphi 2007 live templates schema namespace is defined as "xmlns="http://schemas.borland.com/Delphi/2005/codetemplates" but unfortunately borland.com isn't available any more. Have anybody seen/have backup of this schema? Is this namespace…
g2mk
  • 509
  • 3
  • 13
2
votes
0 answers

IDEA plugin development:how to execute some custom actions while editing live templates?

I am developing a plugin to enhance the live template function of IDEA. Consider the editing box when refactoring the name of a variable: While typing code in such a replacement box, I want to get the text after finising inputting and do something,…
tia
  • 21
  • 1
2
votes
1 answer

the logt abbreviation not work in AndroidStudio live templates

The logt abbreviation not work, but logd or logm works, in AndroidStudio live templates. When input logt, it generates private static final String TAG = "Cannot invoke method length() on null object";, and its expression is…
AnswerZhao
  • 366
  • 3
  • 13
2
votes
1 answer

Why ist "Edit Variables" is disabled for IntelliJ live tempates?

I want to define a live template in IntelliJ. Unfortunatley I cannot use any variables and the "Edit Variables" buttons remains disabled for new templates. Any ideas how to get variable substitution working?
BetaRide
  • 16,207
  • 29
  • 99
  • 177
2
votes
1 answer

how to create Intellij live templates in a custom language "context"?

I am building a custom language plugin for a custom language. I would like to add some live templates for this language, but the new language is not showing up on the list of available contexts in the "Change Context Type For Selected Templates"…
2
votes
1 answer

PhpStorm live template expression to convert current variable

So we can use expressions to transform other variables in live templates. For example: Is it possible to apply snakeCase to NAME directly? So whatever I type, gets converted into snake case? Desired result: Tried snakeCase(NAME),…
unxp
  • 318
  • 2
  • 12
2
votes
1 answer

Pycharm turn off HTML tag creation while in Live Template

I created a simple live template called href: $text$$END$ Order is $text$ then $href$ but after filling in the $text$ variable and pressing TAB instead of jumping to $href$ it instead creates an html tag. For example when I…
enchance
  • 29,075
  • 35
  • 87
  • 127
2
votes
1 answer

IntelliJ live template. Remove or replace number at the beginning of filename

I have database migration files with timestamp at the beginning of the filename. For example: 1537865596694-create-config-table.migration.ts There is expression you can use to convert filename to Typescript class…