live-templates

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

你说的曾经没有我的故事 提交于 2019-12-21 07:07:30
问题 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 generated automatically by some algorithm. UPDATE I want to clarify a little bit what I want to achieve. Suppose I want to create setter with name setTime which has parameter time . public void setTime(long time) { // ... } I don't want to type "time"

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

安稳与你 提交于 2019-12-21 07:07:15
问题 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 : 回答1: You could use String Manipulation plugin to do that ( Increment/Decrement | Increment duplicate numbers ). 回答2: The plugin is not working on my WebStorm, there could be another way using unix command line: seq 1 10 | xargs printf 'string%d\n' 回答3: Tried plugin "String Manipulation" ... But (7.2.182.000.3 June18,

Transferring Intellij Live Templates Between Machines

荒凉一梦 提交于 2019-12-10 10:26:23
问题 I'm trying to figure out how to transfer the templates in the /.IdeaC10/config/templates/user.xml file to my coworker's machines. If I copy into the user.xml file, then those changes seem to be getting squashed by Intellij, reverting to the old file contents. Anyone know how to work around this? EDIT: Is there any way to do this by copying and pasting the xml? That would be preferrable...! 回答1: Use File | Imprort/Export Settings. 回答2: the technique of copying and pasting the xml file on

Transferring Intellij Live Templates Between Machines

我只是一个虾纸丫 提交于 2019-12-06 02:27:26
I'm trying to figure out how to transfer the templates in the /.IdeaC10/config/templates/user.xml file to my coworker's machines. If I copy into the user.xml file, then those changes seem to be getting squashed by Intellij, reverting to the old file contents. Anyone know how to work around this? EDIT: Is there any way to do this by copying and pasting the xml? That would be preferrable...! Use File | Imprort/Export Settings . the technique of copying and pasting the xml file on another computer in the correct directory, function perfectly for me! But the name of my template file is android.xml

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

自古美人都是妖i 提交于 2019-12-05 09:08:50
问题 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 see default values already typed which I can change or leave as it is. Like this But no. I have empty strings instead of default values Why? 回答1: I was wrong about Default value field. I don't need this in my case. I need to fill Expression field.

How to pass variable to groovy code in Intellij IDEA live templates groovy script?

三世轮回 提交于 2019-12-04 05:56:52
I have a groovyScript in my Intellij IDEA live template, like this : groovyScript("D:/test.groovy","", v1) on my D:/test.groovy i have a code like this: if ( v1 == 'abc') { 'abc' } Now I want to pass v1 variable into test.groovy ,can any one help me how can I do this? For exemplification purposes I made a live template which is printing a comment with the current class and current method. This is how my live template is defined: And here is how I edited the variableResolvedWithGroovyScript variable: The Expression for the given variable has the follwing value: groovyScript("return \"// Current

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

删除回忆录丶 提交于 2019-12-03 03:54:50
问题 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. 回答1: There is OpenAPI for providing Live Template functions. One can

Current file path in Live Template

泪湿孤枕 提交于 2019-12-02 00:21:44
问题 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 as I was hoping for. Thanks! 回答1: According to the docs (emphasis mine): You can use groovyScript macro with multiple arguments. The first argument is a script text that is executed or a path to the file that contains a script. The next arguments

Intellij Live Template

人走茶凉 提交于 2019-11-30 11:42:00
问题 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 = Logger.getLogger($CLASS$.class) It seems unnecessary to type $CLASS$ every time when this live template is used, because it can be derived from the class in scope or filename. I was wondering if it is possible to use environment defined tokens in live

Intellij Live Template

萝らか妹 提交于 2019-11-30 01:07:27
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 = Logger.getLogger($CLASS$.class) It seems unnecessary to type $CLASS$ every time when this live template is used, because it can be derived from the class in scope or filename. I was wondering if it is possible to use environment defined tokens in live templates as defaults? Check some other templates that already use the current class name: log4j: