Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 12e068ccc85a59b6be0dd44045903d58571f7aab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!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>Content Assist</title>
	<link rel="stylesheet" type="text/css" href="../help.css">
</head>

<body>

<h1>Content Assist</h1>

<p>Content Assist is a set of tools built into the CDT that can reduce the number of keystrokes you must
type to create your code.  The Content Assist plugin consists of several components that forecast what 
a developer will type, based on the current context, scope, and prefix.</p>

<h2>Code completion</h2>

<p>Content assist provides code completion anywhere in the document. For the current project a list is 
displayed of the elements that begin with the letter combination you entered, and 
the relevance of each proposal is determined in the following order:</p>

<ul>
  <li>Fields</li>
  <li>Variables</li>
  <li>Methods</li>
  <li>Functions</li>
  <li>Classes</li>
  <li>Structs</li>
  <li>Unions</li>
  <li>Namespaces</li>
  <li>Enumerations</li>
</ul>

You trigger the Code completion feature when you call Content Assist (such as when you type <tt>Ctrl+Space</tt>), but it is autoacivated you type 
&quot;<b>.</b>&quot;, &quot;<b>-></b>&quot; or &quot;<b>::</b>&quot;.</p>

<p><img src="../images/contentAssist_example.png"  alt="C++ example showing Code Assist popup"></p>

<p>You can view the signature of each item on the list in a pop-up by pointing to it. You can then select an item in the list to  insert it directly into your code. </p>

<h2>Code templates</h2>

<p>You can create and save code templates for frequently used sections of code, which will be inserted according to scope. The Content Assist feature also provides quick access to code 
templates.</p>

<p>When you enter a letter combination in the C/C++ editor, and type <tt>CTRL+SPACE</tt> (or right-click and click <b>Content Assist</b>), a 
list of code elements and code templates that start with the letter combination that you typed is displayed.</p>

<p>You can then select a code template from the list and it is inserted directly into your code.</p>

<img src="../images/editor_c_codetemplates_use.png"  alt="C++ example showing Code Assist popup"></p>

<p>For example, the code template <samp>do while statement</samp> contains the following code:</p>

<p><img src="../images/codetemplates_example.png"  alt="Code Template showing do-while example"></p>

<p> When you select the <samp>do</samp> code template from the list, you insert the following code:</p>

<p><pre>do {
} while (condition);</pre></p>


<p>If the completion engine finds only one proposal in your templates, that proposal is inserted at the current cursor position.  
For example if you create a new .cpp file and type <tt>mai+CTRL+SPACE</tt> the following code is inserted at the cursor location:</p>
<p><pre>int
main(int argc, char **argv) {
	
}</pre></p>

<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
<br>
<a href="cdt_o_code_entry.htm">Code entry</a></p>
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
<br>
<a href="../tasks/cdt_t_contentassist.htm">Using Content Assist</a><br>
<a href="../tasks/cdt_t_add_codetemp.htm">Creating and editing code templates</a><br>
<a href="../tasks/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_icons.htm">C/C++ perspective icons</a></p>

<p>

<img src="../images/ng03_04.gif" ALT="IBM Copyright Statement" BORDER=0 width="324" height="14"></p>

</body>

</html>

Back to the top