I could not find the live templates for Java! Who can tell me how to set? Thanks.
They're inside all the nodes that are not specific to another language than Java: iterations, output, plain, surround, etc.
As JB Nizet wrote there is not a special node for Java (but you can create one). If you want your own Live Template for Java created do the following.
Open Settings window (File -> Settings)
Click on Editor -> Live Templates
Choose Template Group in which you want to add your Live Template
(you can create your own Template Group if you wish)
Click on + icon and choose Live Template
Specify the Abbreviation, Description and Template text.
Do not forget to define the context (in your case Java)
Example
Here is an example of how to create your own TODO text
Open the Setting window with Live Templates editor (as specified above).
Click on + icon and select Template Group.
Name this group Java.
Click on + icon again and select Live Template.
Specify your Live Template and DEFINE CONTEXT.
In my case writing mtodo and pressing enter will result in:
// TODO myName
You can even use variables. Write in your Template text e.g. $DATE$ and $TIME$
// TODO myName $DATE$ $TIME$
Click on Edit variables button and assign to each variable (defined by dollar sign) and expression (predefined function).
Now mtodo will result in
// TODO myName 13.10.2015 15:39
Predefined functions could be found here. The example was created using IntelliJ IDEA 15 EAP.
For those of you who have taken Postfix completion for Live templates, it is worth mentioning they are different. from not-choosing pretty good answers from #JB Niznet and #vitfo, I guess that's the case for OP writer. The document, here, says:
Postfix code completion is similar to live templates, it transforms the current expression without selecting it. For example, you can type .if after an expression to invoke the corresponding postfix completion and wrap the expression with an if statement.
You can check out a list of postfix completions:
Open the Preferences window
Click on Editor -> General -> Postfix completion
By default, there is no JAVA group in this setting page.
However, these default settings distribute on each feature group. For example, iterations:
IntelliJ IDEA 2019.2.4 (Ultimate Edition)
Related
I would like that when I write the name of a property and I tab to autocomplete, it put "this" prefix automatically.
For exemple:
If I tab, I get this:
I would like to have this instead:
There are my visual studio settings, Resharper settings and editorConfig:
(Edit: I've opened a feature request: https://developercommunity.visualstudio.com/t/Visual-Studio-2022-auto-prefix-propertie/10221630)
(Edit 2: The language is C#)
This would need to be a feature request. You can submit that through VS with the Suggest A Feature on the feedback menu.
When you press tab to commit the completion item, the text to insert (or "insertion text") for that item has already been calculated. In most cases, it is the text seen (known as the display text), but sometimes the insertion text can be different (or even include edits other places in the document!). There is also the possibility, depending on how each language implements the completion feature, that the language can make additional calculations and edits as part of committing the item.
In either event (pre-computed or computed during commit), the language feature would need to make changes to include the this. prefix as part of the completion commit edit.
A possible alternative to waiting for a new feature would be to write an editor extension that monitors the buffer changes, and when it sees an applicable member inserted without the required this. prefix, it could then trigger its own edit automatically to insert it.
I'm trying create a custom shortcut in IntelliJ to generate some predefined comments.
For example, if I write //-- and press enter, it should auto-generate:
//------------------------------------------------------------------------------//
//------------------------------------------------------------------------------//
The Postfix Completetion feature looks like it could be used for this but I didn't figure out how to set it up for this scenario. Can someone help?
If Postfix Completetion is not the answer, can I do it with another feature?
You can create a Live Template (Preferences | Editor | Live Templates). For example, a template like the following:
//------------------------------------------------------------------------------//
$END$
//------------------------------------------------------------------------------//
The $END$ indicates where the text cursor will be placed when the Live Template text is inserted. At the bottom of the Live Template settings screen you can configure in which languages/contexts the Live Template should be available.
I was wondering. Is it possible to add number shortcut to corresponding actions inside Intention Actions window? Like with String Manipulations plugin:
For example in this case:
I would love to press Alt+Enter and then 3 to Create object buzz - I know for a lot of cases I can use shortcut for example ctrl+alt+v for a variable extraction but not for all.
I was looking for this kind of plugin but without a result
In the settings window of Phpstorm, there is a dropdown box labelled scheme
What does it do?
What does it do?
You may be surprised .. but it allows you to choose another (different) Code Style scheme for this project.
PhpStorm supports globally defined schemas (by default it provides only one -- "Default") which can be used by any project and project-specific schema called "Project" which available for this project only (and stored together with other project-specific settings).
You can read more in official help page.
The Code Style is used for code formatting: be it automatic as you type / use live templates etc .. or manual reformat via Code | Reformat Code...
It's used to
choose the code style scheme to be used as the base for your custom coding style for the selected language (Source).
In other words: after selecting a scheme, you can set different formatting options, like tabs vs spaces, tab size or line breaks etc. To use those settings in your current project, you need to click Manage, select your edited scheme and click Copy to Project. After this, you can press Ctrl + Alt + L (Code > Reformat Code...) in the editor to reformat a file according to those scheme settings.
I am debugging in NetBeans IDE, where can I see assigned variables and their values?
While you're in the debugger go Window -> Debugger -> Variables
You can also use ALT+SHIFT+1 to bring up variable viewer.
Generally, the pane underneath the code has some tabs - and one of them will say 'Variables'. Click on that tab and you will see variables and their values. You need to be actually running a debug session before the variables tab is available.
For this to show all local variables you need to have the line:
xdebug.show_local_vars=1
in your xdebug.ini file. Don't forget to restart Apache if you add that line.
If you are not seeing all local variables then you may have hit the problem where your version of the module file (xdebug.so) has a bug. This is the case currently for Ubuntu 10.04.
To fix this you need to compile a newer version of the xdebug.so file. Follow the instructions at http://xdebug.org/wizard.php to get your new file which should replace your current xdebug.so file.
There exists another solution that is
Press Ctrl+F9 to display Evaluate Expression Panel/Tab
Enter variable name in Evaluate Expression Panel/Tab
Press Ctrl+Enter (or arrow icon at right of Evaluate Expression Panel/Tab
The variable's value is then displayed in Variables Panel just below (on my PC) Evaluate Expression Panel/Tab.
You can also use this solution to display EXPRESSION and not only VARIABLE !
Example: (String sSheetData is a String variable that contains a very big string)
sSheetData.substring(4000,4200);
StringTools.Right(sSheetData,100);
StringTools.Mid(sSheetData,4000,200);
This is also possible using New Watch callable using contextual menu.
But this is not as easy as using Immediate Windows on Microsoft Visual Studio :-)