From the main menu, select Code | Generate Alt+Insert to open the popup menu with available constructs that you can generate.
In Eclipse, you press CTRL + SHIFT + O “Organize Imports” to import packages automatically. For IntelliJ IDEA, if you press CTRL + ALT + O “Optimize Imports”, it just removes some unused imports, never imports any package.
Ctrl + H = "Type Hierarchy" view = shows a tree of parent and child classes of this class. Ctrl + Shift + A = "It does a search as you type through all the commands in intellij. Not only that but when you find the command you want it also displays the corresponding shortcut key next to it!"
In past IntelliJ versions, ctrl+shift+f would search the entire project (no matter whether you had at some point used "find in path").
you can use 'live templates' to generate several types of code snippets, loop iteration is done by following -
iter Iterate (for each..in)
itin Iterate (for..in)
itli Iterate over a List
itar Iterate elements of array
ritar Iterate elements of array in reverse order
There are probably many more, just lookup 'Live Templates' in help documentation.
Pressing Ctrl+J opens the list of live templates within your code context. Then type 'itin'.
Aditionally to other answers, you don't even have to use Ctrl + J (but nice for checking what are your possibilities..) Just start type and press Enter:
Foreach: type "iter" then press Enter.
For loop: type "fori" then press Enter.
Idea will recognize the context and suggest the most likely var to iter through, if you like the given options, just press Enters!
Of course, have a look in the help at the default keymap references. Type one of the following and hit "tab":
iter Iteration according to Java SDK 1.5 style
inst Check object type with instanceof and downcast it
itco Iterate elements of java.util.Collection
itit Iterate elements of java.util.Iterator
itli Iterate elements of java.util.List
Create for loop from an existing list statement:
https://www.jetbrains.com/phpstorm/help/creating-code-constructs-using-surround-templates.html
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