Content Assist

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 plug-in consists of several components that forecast what a developer will type, based on the current context, scope, and prefix.

Code completion

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:

You trigger the Code completion feature when you call Content Assist (such as when you type Ctrl+Space), but it is auto-activated when you type ., -> or ::.

C++ example showing Code Assist popup

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.

Templates

You can create and save 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.

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

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

C++ example showing Code Assist popup

For example, the template do while statement contains the following code:

Code Template showing do-while example

When you select the do template from the list, you insert the following code:

do {
} while (condition);

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 mai+CTRL+SPACE the following code is inserted at the cursor location:

int
main(int argc, char **argv) {
	
}

No Completions

If you invoke Content Assist, but no completions are found a message will be displayed on the status to inform you that the Content Assist parser has timed out.

Content Assist No completions available message

Related concepts
Code entry

Related tasks
Using Content Assist
Creating and editing templates
Importing and exporting templates

Related reference
C/C++ perspective icons

IBM Copyright Statement