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?
Use live templates to insert common constructs into your code, such as loops, conditions, various declarations, or print statements. To expand a code snippet, type the corresponding template abbreviation and press Tab . Keep pressing Tab to jump from one variable in the template to the next one.
Live templates are a feature that JetBrains thoughtfully included in IntelliJ, and by extension, Android Studio. By using them, you can quickly and intelligently add frequently used code patterns and constructs to your code, letting the IDE do the tedious work for you.
To navigate to the code where the variable is declared, right-click a variable and select Jump to Source F4 . To navigate to the class declaration of the variable type, right-click a variable and select Jump to Type Source F4 .
I was wrong about Default value field. I don't need this in my case. I need to fill Expression field.
If I want just paste some string as default value I should put this string in quote in Expression. So now my variable settings look this way
And everything works how I want!
If you want a hardcoded string as the default value field (in the edit variables dialog), it needs to be in double quotes ("ii"). Putting a string there with no quotes (ii) does not result in an error, but also does not work.
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