text: Use a Single Editor Well - The editor should be an extension of your hand;
  make sure your editor is configurable, extensible, and programmable.
  -- The Pragmatic Programmer
  See also NetBeans IDE Hacks table of contents
  source 1,
  source 2
  Refactoring is the use of small transformations to restructure code
  without changing any program behavior.
  Just as you factor an expression to make it easier to understand or modify,
  you refactor code to make it easier to read, simpler to understand, and faster to update.
  And just as a refactored expression must produce the same result,
  the refactored program must be functionally equivalent with the orginal source.
  You should always perform a clean build after completing any refactoring commands.
  You can do a clean build by right-clicking the project's node in the Projects window,
  and selecting Clean and Build Project from the menu.
  source 1
  source 2,
  source 3
  Despite our best planning, it happens that we need to change data types we use in classes:
  The field that was an int before, is now an int array.
  Luckily, you did not expose the field publicly — it would have taken you a while to hunt down
  and update all the broken classes that would have accessed this field directly.
  Instead, you encapsulated the field:
  int
  int array
  Encapsulating a field simply means accessing it only via getter and setter methods.
  If a data type changes, you often get away with just updating some getters and setters,
  which saves you a lot of time and nerves.
  Either right-click in the editor, or go to the main menu to see how
  the IDE's Refactoring commands can quickly encapsulate your fields
  by creating getter and setter methods.
  getName
  Another nice little timesaver when modifying existing getters and setters are the prepend shortcuts.
  With these shortcuts, you can for instance quicky turn public int size() into
  public int getSize().
  Place the cursor before a method identifier, e.g. before |size().
  public int size()
  public int getSize()
  |size()
  set
  get
  is
  source
  Often when you copy a code snippet into your sources, the snippet does not contain
  import statements and the code does not compile.
  In these cases, the Editor shows a red warning box next to the line
  of code. If you move the mouse over the box, a hint explains
  that one of the symbols could not be found.
  When you are certain the symbols exist in your path (and the error is not due, say, a typo)
  press Alt-Shift-F to have the IDE fix the missing import statements automatically.
  You can also call this function by right-clicking in the Editor and selecting Fix Import Statements.
  Abbreviations save you a lot of time: Instead of repetitively typing
  the same common and tedious code fragments,
  you type only a few letters and then immediately hit the spacebar.
  The IDE replaces the mnemonic by the full code template.
  fori
  for (int i = 0; i < args.length; i++) {
  |
  }
  for
  Typing sout and space completes to...
  sout
  System.out.println("");
  psfs and space completes to...
  psfs
  private static final String
  You can check out the list of available code templates by selecting
  Tools > Options > Editor > Code Templates from the menu.
  In this preference panel, you can also define your own abbreviations for any code you commonly use.
  Here's a list of special identifiers
  you can use in the templates.
  The IDE can help you if your code does not compile.
  For instance, when you need to implement abstract methods
  in a class that extends another class. As long as you have not implemented all
  methods required for the class to compile,
  a red warning box will appear next to the class declaration.
  Position the cursor into the declaration, and a lightbulb symbol will appear.
  Clicking the lighbulb always displays a hint how to fix the class.
  In our example the hint would suggest to "Implement all abstract methods."
  To make the IDE execute the hint, either click it, or press Alt-Return.
  The IDE generates skeletons of all necessary abstract methods,
  or whatever it was the hint contained.
  See also "Override Any Method Fast".
  toString
  See also "Implement Abstract Methods Fast"
  Want to know the arguments to a method call? Then press Alt-P while writing the call.
  This shows a quick cheat-sheet of expected arguments for the method you are writing.
  Often you need to
  surround a method with a try-catch statement
  because it can throw an exception that should be caught.
  import java.io.File;
  public class CoffeeMachine {
  public CoffeeMachine() {
  File f = File.createTempFile("coffee", "tmp");
  }
  }
  createTempFile()
  import java.io.File;
  import java.io.IOException;
  public class CoffeeMachine {
  public CoffeeMachine() {
  try {
  File f = File.createTempFile("coffee", "tmp");
  } catch (IOException e) {
  |
  }
  }
  }
  The line which performs a dangerous IO operation was surrounded by a try-catch block.
  Notice that the correct import was added into the list of imports as well.
  The cursor gets placed in the catch block:
  Now it's time for you to write code how to respond to the exception being thrown.
  NetBeans has a built-in file comparison function,
  diff,
  to highlight differences between two files.
  Most people know the Diff View from the IDE's versioning support.
  But did you know that you can diff files even if they are not version controled?
  Note that Diff only appears in the Tools menu when two files are selected and in focus.
  Graphical diff in NetBeans
  source 1,
  source 2,
  source 3
  The Search & Replace command (Ctrl-H) supports searching for regular expressions:
  For instance searching for the escape sequence of two newline characters "\n\n"
  will find all lines that are followed by an empty line.
  Unfortunately, the Replace With field doesn't support escape sequences yet.
  So what to do if you want to replace two newline characters by one?
  \n\n
  Despite not yet interpreting escape sequences, the Replace With field already supports back-references.
  This means you can use a back-reference to smuggle the newline character "\n" into the Replace With field:
  \n
  Using this neat trick, you can easily replace two newlines by one.
  Of course, this does not only apply to newlines, but to any regular expression.
  Some examples for symbols most commonly used in regular expressions are
  \w
  \t
  Regular expressions in combination with back-references
  are extremely powerful tools when replacing text. Intrigued?
  This is how they work: Basically,
  each substring that is surrounded by brackets in the search term is 'copied',
  and can be 'pasted' into the replace term. You paste the first bracketed substring
  into the replace term by writing $1, the second one by writing $2, and so on.
  $1
  $2
  For example, you have a long row of variable declarations:
  ...
  public int x;
  public int y;
  public int z;
  ...
  private int x = 0;
  private int y = 0;
  private int z = 0;
  Obviously, you cannot use basic Replace due to the unique variable names.
  Variable names are composed of one or more alphanumeric characters;
  and as a regular expression, a sequence of alphanumeric characters is expressed as \w+.
  Knowing this, you can capture the variable names from the search term
  with the bracketed (\w+) symbol,
  and restore them in the replace term by calling the back-reference $1 symbol.
  \w+
  (\w+)
  Find What: public int (\w+);
  Replace With: private int $1 = 0;
  Remember you can use $2, $3, etc,
  for the following substrings if you reference several bracketed expressions at once.
  $3
  The symbol $0 stands for the whole search term.
  For instance this is useful to close each <img ... > tag in an HTML file
  by replacing it with <img ... />. In regular expressions, the [^] symbol
  is used for negation, therefor [^>]+ matches a string of
  any characters but a closing bracket.
  $0
  <img ... >
  <img ... />
  [^]
  [^>]+
  Find What: <img [^>]+
  Replace With: $0 /
  Regular Expression Quick Start.
  This nifty editor feature saves you a lot of time you would spend with manual editing —
  And you'll impress people with your coding speed as well.
  source 1,
  source 2
  Did you know that NetBeans IDE can convert text to
  UPPER CASE or lower case?
  Select the String, then
  source
  NetBeans supports Smart Selection, a very popular IDE feature.
  Use Smart selection to select whole chunks of code with only one keystroke:
  The first keystroke selects the expression, the second the statement,
  the third the whole block, the fourth the method, and the fifth the whole class.
  This is how you use it:
  Try it! Smart Selection is extremely useful when copying and pasting code.
  How often do you go to the Project view,
  scroll down and search for a file inside the project,
  and then double-click it to open it in editor?
  Doing this is probably fine when you work on small projects.
  But as the project grows, the tree hierarchy to scroll through grows bigger, too.
  And what if you do not remember in which package the class is that you want to edit?
  Instead of browsing huge project trees manually to find a class,
  open the file directly by invoking the Go To Class dialog (Alt-Shift-O).
  Just type in the first letters of the class's name until it is unique.
  Press enter and the file opens in the Editor.
  Click on screenshot for a demo.
  source 1,
  source 2
  Instead of scrolling up and down in the Editor window with the mouse,
  you can navigate very fast to a method or field in the source editor:
  Note that the Navigator contains both a Members view and an Inheritance
  view of your class. If you hover over Navigator items with the mouse,
  it will present you with a quick peek at their APIs by showing the Javadoc.
  source 1,
  source 2
  You are staring at a method call or variable in a class, and cannot for the life of you
  remember were you originally defined the thing. Wouldn't it be great if
  you could directly jump to the definition, make a quick fix, and jump back again? You can!
  Hover your mouse over the sources in the Editor and hold down the ctrl key.
  The text color of the element under the mouse changes to blue and
  it becomes underlined, just like a hypertext link in a web browser.
  With a single left click, you directly jump to the source
  where this element was defined.
  If the cursor is positioned within the element,
  the keyboard shortcut Alt-G will equally take you to the definition.
  Now you want to get back to your original source location —
  Did you ever notice that little yellow arrow in the editor bar?
  Click on it and it will take you back to every previous cursor position in the source code!
  The keyboard shortcut Alt-K will equally take you back.
  Both the Back button and the Alt-K shortcut jump back to the previous cursor position,
  even if you did not use a hypertext link to jump there.
  source
  A good programmer breaks a project down into several classes with independent tasks, right?
  But what does a good programmer do when he has so many files open
  that they no longer fit the screen — scroll? Nope: He switches tabs.
  This is how you do it:
  Note however, that in some operating systems, Ctrl-Tab is already associated with
  another conflicting action. In this case, use Ctrl-~ instead. (Thanks to Jesse Glick for this tip.)
  You have a file open in the Editor, how do you quickly find out to which project it belongs?
  Easy, you say: You point at the file's tab, and the tooltip that pops up shows the file path.
  But you want to call a context-sensitive command on the file node in the Projects View.
  Obviously, you don't want to drill down the whole path manually,
  double-clicking all the intermediate nodes. Isn't there an easier way? There is.
  Note that these commands are only meaningful if the file's source root
  is already open in the Explorer.
  Bookmark this page
  This collection of NetBeans hacks is a community effort --
  this means you can help us collect more NetBeans tips & tricks.
  Send your favorite hack in and we'll include it!
  (We reserve the right to edit, republish, or not use your hacks.)