Netbeans Tricks and Tricks on Live Examples
Very often I hear phrases of various people about the fact that a full-fledged IDE is not necessary, that Vim, Sublime Text and Atom allow you to do everything, and so on and so forth. Only recently I again had a conversation on this topic, and I again remembered that I wanted to show people some of the tricks of modern IDEs that greatly simplify life during work.
I love this quality open source IDE Netbeans IDE. I even have a color scheme for her own (do not forget to read the description if you want to try it out). On all videos, it’s used in the work, plus the dark interface Darkula and the free font Hack .
Sometimes I go to PhpStorm, work there and compare the capabilities of these two IDEs. And from time to time I come to understand that each of them is good in its own way. PhpStorm has many interesting smart features for quickly developing OOP code. On the Netbeans side, it's free, as well as a powerful and slightly overloaded interface. This is especially felt after returning to it with PhpStorm.
In this article, I would like to show some cool tricks that are present in Netbeans and other modern IDEs, and some of them only in Netbeans. Very often they help me save a lot of time when working on large projects.
Please also do not resent those people who use modern IDEs and know most of these tricks. This is not for you! The fact is that there are many other people who do not know them, and I would like to show them these opportunities with a real example.
Entity navigation in a file
One of my favorite Netbins features. PhpStorm also exists, but is made a little less convenient .
Hover over a variable, wait for it to highlight. Then press alt + up / down to go to the places where this variable is used in the file.
Open all modified files in the project
Suppose you have a need: quickly understand what specific changes are currently present in the current project, as well as analyze and adjust them. In a normal situation, you can write
git statusand see a list of files that are changed. In the case of Netbeans, it's still simpler:
Do you have a large file with a bunch of code that looks awful? No problem, just press Alt + Shift + F and Netbeans will make it sweet :)
You can very flexibly customize how Netbeans will format your code. If necessary, for a separate project, you can save your own formatting settings, store them in the project repository and use them with your entire team.
And if you press Alt + Shift + F while on some folder of your project in the file tree, then Netbeans will help you to recursively format all the code in this folder.
Highlighting incorrectly used or unused variables and methods
PhpStorm clearly outperforms Netbeans in this regard due to a much larger variety of smart checks and suggestions for auto-correcting code.
Did someone refactor the code and leave behind some meaningless variables? No problem, Netbeans will show you them and offer to remove or fix incorrect behavior.
Intelligent Correction Use Directives
With the advent of PSR standards in the world of PHP, the source code of the projects was transformed and began to actively use namespace. Now every PHP class has a whole bunch of use directives that indicate which specific dependencies this class uses.
To make it easier to work with all this, Netbeans has a feature for automatically correcting these directives. Simply press a combination of the Ctrl + I of the Shift + .
PhpStorm does just about the same, but a little more elegant and smarter.
When we have a dozen tabs open, it happens that you really want to quickly move one of them between them. Yes, you usually have to do this with the mouse, but it’s much more convenient when such an opportunity is right in the keyboard combination!
This combination must be set manually through the settings. I hung this on Alt + Shift + PgUp / PgDn
In PhpStorm this is still not implemented.
Editing a variable in a file / project
You have unsuccessfully named a class, and it would be nice to rename it? Or did the same thing happen to one of your variables? There is nothing easier if you have Netbeans or another similar IDE at hand.
To edit a variable or class, move the cursor to the desired object and press the combination of the Ctrl + the R .
Auto Generation of Getters and Setters
Sometimes we create some new class, and in accordance with the approach of the ADT (abstract data types), it will be correct if we set getters and setters for all the necessary class variables. Smart IDEs come to our aid again, which may well do all this for you.
Create a new class and define all its variables, then press Alt + Insert .
It happens that we write a class that depends on another class, and we need to override one of the methods of the parent class. Here the Alt + Insert combination helps us again .
Search Results Navigation
We all know that very often in a project it is necessary to find some kind of the same design, and do something with it. In this case, the presence of hot keys helps to navigate the search results: Ctrl + [dot / comma] . Netbeans will automatically open the necessary files and switch the cursor to the desired line. This greatly facilitates the work with large refactoring.
Highlighting a wider / narrower block of code
A very interesting feature that Netbeans has, but I rarely remember about it :) Pressing alt + shift + [dot / comma] selects a larger / smaller area relative to the initial cursor position. This should also be seen in a real example in order to better understand:
That’s all for now, and I hope this article will help you and facilitate your work :)
And of course, it will always be interesting to read in the comments about other IDEs and other favorite tricks that other programmers use in their daily work. Go ahead :)