Very often I hear the phrases of various people on the theme that full-fledged IDEs are not needed, that Vim, Sublime Text and Atom allow you to do everything, and so on and so forth. Only recently I had a conversation on this topic again, and again I remembered that I wanted to show people some of the tricks of modern IDE, which greatly simplify life during work.
I love this quality open source Netbeans IDE. I even have my own color scheme for it (do not forget to read the description if you want to try it out). In all the videos, this is exactly what is used in the work, plus the dark interface Darkula and the free font Hack .
Sometimes I switch 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 intellectual features for the rapid development of OOP code. And on the Netbeans side, it's free, as well as a powerful and not very 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 are only in Netbeans. Very often they help me save a lot of time when working on large projects.
I also ask you not to 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 possibilities with a real example.
One of my favorite favorite features of Netbins. In PhpStorm also exists, but made a little less convenient .
Hover over a variable, wait until it is highlighted. Next, press alt + up / down to go to the places where this variable is used in the file.
Similarly, you can highlight some method or class name and navigate to their uses in the file. Similarly, you can navigate to entities in other programming languages, for example, in JavaScript.
Suppose you have a need: to quickly understand what specific changes are currently present in the current project, as well as analyze and correct them. Normally, you can write git status
and see a list of files that have changed. In the case of Netbeans, it's still easier:
Do you have a big file with a bunch of code that looks terrible? No problem, just press Alt + Shift + F , and Netbeans will make it sweet :)
You can be very flexible about 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 whole team.
And if you press Alt + Shift + F while being on some folder of your project in the file tree, Netbeans will helpfully recursively format all the code in this folder.
For this part, PhpStorm clearly wins over Netbeans due to a much larger number of various intellectual checks and suggestions for auto-fixing the code.
Has someone refactored the code and left behind a few meaningless variables? No problem, Netbeans will show them to you and offer to remove or correct incorrect behavior.
With the advent of PSR standards in the PHP world, the source codes of the projects were transformed and began to actively use neimspaces. Now, every PHP class has a whole heap of use directives that indicate which dependencies the particular class uses.
To make it easier to work with all this business, Netbeans has an auto-correction feature for these directives. Just hit Ctrl + Shift + I.
PhpStorm does the same thing, but a little smarter 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 it with the mouse, but it’s much more convenient when you have such an opportunity right in the keyboard combination!
This combination must be set manually through the settings. I hung it myself on Alt + Shift + PgUp / PgDn
PhpStorm has not yet implemented it.
You unsuccessfully called a class, and it would be good to rename it? Or did the same happen to one of your variables? Nothing is easier if you have Netbeans or another similar IDE on hand.
To edit a variable or class, hover over the desired object and press the Ctrl + R combination.
Sometimes we create a 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. Once again, smart IDEs come to our rescue and can do all this for you.
Create a new class and define all its variables, then press the Alt + Insert combination.
It happens that we write a class that depends on another class, and we have a need to override one of the methods of the parent class. Here again the Alt + Insert combination helps us.
We all know that very often in the project it is necessary to find some kind of the same type of construction, and to do something with it. In this case, the presence of hotkeys to navigate the search results helps in the work: Ctrl + [full stop / comma] . Netbeans will automatically open the necessary files and switch the cursor to the desired line. This greatly facilitates the work with a large refactoring.
A very interesting feature that is found in Netbeans, but about which I remember quite rarely :) Pressing alt + shift + [dot / comma] highlights the larger / smaller area relative to the initial position of the cursor. This should also be seen in a real example in order to better understand:
That's all for now, and I hope that this article will help you and make your work easier for you :)
And of course, it will always be interesting to read in comments about other IDE and other favorite tricks that other programmers use in their daily work. Dare :)
Source: https://habr.com/ru/post/320666/
All Articles