blob: c98e080a8175f80274df4822e810c32edf570805 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<title>Templates</title>
</head>
<body>
<h1>Templates</h1>
<p>Templates are a structured description of coding patterns that reoccur in
source code. The Java editor supports the use of templates to fill in
commonly used source patterns. Templates are inserted using content
assist (<strong>Ctrl+Space</strong>).</p>
<p>For example, a common coding pattern is to iterate over the elements of
an array using a for loop that indexes into the array. By using a
template for this pattern, you can avoid typing in the complete code for the
loop. Invoking content assist after typing the word <code>for</code> will present
you with a list of possible templates for a for loop. You can choose the appropriate
template by name (<code>iterate over array</code>). Selecting this template will
insert the code into the editor and position your cursor so that you can
edit the details.</p>
<p>Many common templates are already defined. These can be browsed in
<strong>Window &gt; Preferences &gt; Java &gt; Editor &gt; Templates</strong>.
You can also create your own templates or edit the existing ones.</p>
<p><img border="0" width="159" height="27" src="../images/ngrelt.gif" alt="Related tasks"><br>
<a href="../tasks/tasks-171.htm">Using templates</a><br>
<a href="../tasks/tasks-203.htm">Writing your own templates</a>
</p>
<p><img border="0" src="../images/ngrelr.gif" alt="Related reference" width="159" height="27"><br>
<a href="../reference/ref-menu-edit.htm">Edit menu</a><br>
<a href="../reference/ref-143.htm">Java Content Assist</a><br>
<a href="../reference/ref-preferences-templates.htm">Templates preferences</a><br>
</p>
<p><br>
</p>
<p>&nbsp;<a href="../hglegal2003.htm"><img src="../images/ngibmcpy2003.gif" width=324 height=14 alt="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." border="0"></a></p>
</body>
</html>