1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
cdt/doc/org.eclipse.cdt.doc.user/tasks/cdt_t_add_codetemp.htm

90 lines
No EOL
3.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Creating and editing code templates</title>
<link rel="stylesheet" type="text/css" href="../help.css">
<script language="JavaScript">
function changeSize(theImage,wd,ht) {
wdth=parseInt(theImage.style.width); hght=parseInt(theImage.style.height);
if ( !(wdth==(wd*2)) ) {wdth=wd*2; hght=ht*2;}
else {wdth=wd;hght=ht;}
theImage.style.width=wdth; theImage.style.height=hght;
}
</script>
</head>
<body>
<h1>Creating and editing code templates</h1>
<p>Code templates are stored in templates.xml in the org.eclipse.cdt.ui and
org.eclipse.jdt.ui folders. </p>
<p>To create a code template:</p>
<ol>
<li>Click <b>Window &gt; Preferences</b>.</li>
<li>Expand <b>C/C++</b>, and click <b>Code Templates</b>.</li>
<li>Click <b>New</b>.<br>
<img src="../images/code_templates_new.png" width="365" height="304" onClick="changeSize(this,365,304);"
alt="Screen capture for inserting a new Code Template" title="click to toggle image size">
</li>
<li><p>Do the following:</p>
<ul>
<li>In the <b>Name</b> field, enter a template name.</li>
<li>Click the <b>Context</b> button and select a template type: <b>C</b> or <b>C++</b>.</li>
<li>In the <b>Description</b> field, enter a description for your new
code template.</li>
<li>In the <b>Pattern</b> field, enter the code for your template.</li>
<li>Click <b>Insert Variable</b> to add a variable from the list to the
code you have entered in the Pattern box.</li>
</ul>
</li>
<li>Click <b>OK</b>.<br>
The new code template is now displayed in the list.</li>
</ol>
<p>To edit a code template:</p>
<ol>
<li>Click <b>Window &gt; Preferences</b>.</li>
<li>Expand <b>C/C++</b>, and click <b>Code Templates</b>.</li>
<li>Click <b>Edit</b>. The New Template dialog box opens.<br>
<img src="../images/code_templates_edit.png" width="368" height="269" onClick="changeSize(this,368,269);"
alt="Screen capture for editing a Code Template" title="click to toggle image size">
</li>
<li><p>Do the following:</p>
<ul>
<li>In the <b>Name</b> field, change the template name to create a new
template based on the current template. </li>
<li>Click the <b>Context</b> button and select a template type to change the nature of the template.</li>
<li>In the <b>Description</b> field, change the description of the code
template to reflect your changes.</li>
<li>In the <b>Pattern</b> field, edit the code.</li>
<li>Click <b>Insert Variable</b> to add a variable from the list to the
code you have edited in the Pattern box.</li>
</ul>
</li>
<li>Click <b>OK</b>.</li>
</ol>
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
<a href="../concepts/cdt_c_content_assist.htm">Content Assist</a></p>
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="cdt_t_contentassist.htm">Using Content Assist</a><br>
<a href="cdt_t_imp_code_temp.htm">Importing and exporting code templates</a></p>
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21"> <br>
<a href="../reference/cdt_u_code_temp.htm">Code Templates page, Preferences window</a><br>
<a href="../reference/cdt_u_code_temp.htm">Code Templates page</a></p>
<p>
<img src="../images/ng03_04.gif" ALT="IBM Copyright Statement" BORDER=0 width="324" height="14">
</body>
</html>