NetBeans 8.2 is scheduled to be released end of summer 2016. One popular feature is called pin watches. During a debug session you may define several watches in the variable window to view the current content of a variable or value expression. With pin watches you may pin such a watch directly to the source code. Amongst others Geertjan described this amazing feature in his blog [1].

Today I’m going to describe another upcoming feature, which is yet available if you download a nightly build [2]: Editor Multicarets.A caret is the position where the editor has input focus. And multicarets are multiple positions with input focus.

To present the function, with a real world use case, let’s assume we have a class containing a quantityId of type int.

private int _quantityId;

public int getQuantityId() {
       return _quantityId;
}

public void setQuantityId(int quantityId) {
       _quantityId = quantityId;
}

Now we want to replace this by qantityClass of type QuantityClass. NetBeans offers a powerful rename feature. Click onto _quantityId and invoke rename {Ctrl+R}. Beside the field, NetBeans is able to rename the getter and setter too (you may need to check Rename getter and setter). Perform the same operation on the getter’s parameter too (Maybe some day, NetBeans would rename the parameter whilst renaming the field to avoid the second rename.).

However, you have to perform a last task: You need to change three occurrences of int to QuantityClass. That’s one use case for the multicarets feature.

Place the caret (by mouse or keyboard) onto the first int. Now press {Ctrl+J} and repeat   this for another two times. All three occurrences of int will be selected and a blinking caret appears after each.

MultiCarets 2016-05-07 00-26-26Change it to QuantityClass. Changing one of them, will change all of them!

MultiCaret 2016-05-07 00-31-22The screenshot above shows the three carets during changing the value.

Editor Multicarets can be used with some other keyboard shortcuts. For example, you may select all occurrences of a word in your source file {Ctrl+Alt+Shift+J}. Find all keyboard   shortcuts described at the new and noteworthy site [3].

Enjoy!

[1] blogs.oracle.com/geertjan/entry/new_pin_debugger_watches_in

[2] bits.netbeans.org/download/trunk/nightly/latest/

[3] wiki.netbeans.org/NewAndNoteworthyNB82