rwallace
rwallace

Reputation: 33639

Aiming Netbeans code snippets

Not quite sure whether I'm using the right terminology here, but Netbeans has a very nice feature where e.g. if you start typing for it will offer to write a code fragment looping over an array or list, basing it on the name and type of an array or list variable actually in scope.

If more than one such variable is in scope it will guess, sometimes correctly and sometimes not.

Is there a way to aim this feature at the correct array/list variable?

Upvotes: 0

Views: 68

Answers (2)

Ejaz Ahmed
Ejaz Ahmed

Reputation: 654

In netbeans terminology, it is called code templates (many editors call it code snippets). You can customize them also by going to tools > options > editor and select required language from the dropdow.

Upvotes: 0

D-rk
D-rk

Reputation: 5919

You can do that like this:

  • Type fore and press TAB. This will generate the for each loop.
  • The loop variable is selected. Press TAB again to select the list variable.
  • Finally, press CTRL+SPACE, select a different list variable, and press ENTER.

(Tested with Netbeans 8.0)

Upvotes: 3

Related Questions