Templates
Eclipse provides a shorthand way of entering text called templates. For example, in the Java editor, if you type for and press Ctrl+Space, the code assist window will pop up as before, but this time it will display a few templates that start with the word "for" (see Figure 24).

Figure 6-2. Editor templates are shorthand for entering boilerplate text (e.g., for loops).
Selecting the first one will cause code similar to this to appear in the editor:
for(inti = 0; i < array.length; i++) { }
The cursor highlights the first variable i. If you start typing, all three occurrences of that variable will be modified. Pressing Tab will cause the variable array to be selected; pressing Tab again will put the cursor on the blank line between the braces so you can supply the body of the loop.
Tip
If you try this, you may see different variable names. Eclipse guesses which variables to use based on the surrounding code.
For a list of all predefined templates, and to create your own or export them to an XML file, see Window → Preferences → Java → Editor → Templates.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access