While searching for a NetBeans IDE related topic today, I discovered an absolute gem: a whole page full of useful NetBeans Tips! Have a look at http://wiki.gephi.org/index.php/NetBeans_Tips
I use the search features of the NetBeans IDE a lot. I have collected thousands of pieces of useless information in my life as it is, and I am not planning to add to that memorising every line of code I have ever written. 🙂 So I let my PC do what computers do best – search through large volumes of data. This has become an integral part of how I work, but I realised this week that not everybody knows about all the cool things you can do!
The NetBeans IDE have a number of very useful searching features. The first, and probably most obvious, is searching through the currently selected source file. I created two new Windows in a platform application module through the wizard for illustration purposes. I opened one of the TopComponent classes in source view, and pressed Ctrl + F and typed in my search term. See the figure below.
Notice that a search bar appeared at the bottom of the editor window, where I entered my search string. And as I typed, matching words were highlighted throughout the currently selected source file. The highlighted words are also marked in the right margin – each of those lines in the margin represent a line where the search term was found. Pressing enter while the Find text box has focus, moves the selection to the next occurrence of the search term.
If you select something in the source file before you press Ctrl + F, that text will automatically be filled in on the search panel.
This is useful but not life changing. 🙂 But searching, like almost everything in the IDE, is context sensitive. So by selecting a project in the projects view, and then pressing Ctrl + F again, you can access the Find in Projects feature.
Since I selected a particular project, that project is selected by default as the scope for the search. Pressing Ctrl + Shift + F instead from anywhere in the IDE, the Scope would by default be “Open Projects”.
Let us look at the search results for the criteria “TopComponent”, searching through my module containing the two Windows.
The list shows all the files where the search criteria were matched, and for each file the list of occurrences within the file. Navigating to the location is as simple as double clicking on the entry.