Compose code sonatas. Become the Chopin of your keyboard.
During pair coding with my fellow Java developers, I’ve noticed that some of them are not familiar with some useful features of IDE. It led me to the idea of writing a series of blog posts about some interesting functionalities/plugins that Intellij Idea provides.
In the future I will provide you some keyboard shortcuts to navigate through projects.
Do you have some red (or yellow) underlined parts in the code? Focus cursor on one of them and press Alt+Enter and see IDE’s suggestions how to fix the issue. To iterate over the issues just use F2.
Do you want to get rid of manual implementation of constructors, getters, setters, toString, equals and hashCode? You can use automatic generation of the code - Alt+Insert.
To extract some part of the code to method - use Ctrl+Alt+M.
Similary you can do this for focused value to extract it to variable using Ctrl+Alt+V, or to constant using Ctrl+Alt+C.
Did you know that you don’t need to manually select the strings, or some grouped parts of the code by a mouse, or arrows? There is a quite simple shortcut to select string, method name, field name or any other part of the code. Just use Ctrl+W to expand the selection, or Ctrl+Shift+W to narrow.
Sometimes you need to write multiple similar lines and pass different parameters. Why write them multiple times? Write the code once and use Ctrl+d to duplicate it. If you need to edit multiple lines use Ctrl+Ctrl(hold)+Arrow.
Instead of using search-replace - focus cursor on variable/constant/class/method and press Shift+F6.
Instead of creating manually test classes you can use the shortcut Ctrl+Shift+T.
Formating and cleaning
Formatting and cleaning. If you have a problem with organisation of the code you can use Ctrl+Alt+L to format the code. If you want to organize the imports use Ctrl+Alt+O, to execute all the formatting features just use Ctrl+Shift+Alt+T.