**** Advance Notice ****

This site will be closed on 31 December 2015,

Important Information for users of NXP LPCXpresso

This site is for users of Code Red branded products.

NXP LPCXpresso users should visit the LPCXpresso FAQ's for up-to-date information relevant to that product.

Editor Hints and Tips

The editor view within Eclipse, which sits under the Code Red IDE, provides a large number of powerful features for editing your source files. These include...

Source folding

Within the editor view, functions, structures etc may be folded to show the structure and hide the detail.

To enable folding, right click in the margin of the editor view to bring up the context sensitive menu, then select Folding->Enable Folding, or the keyboard shortcut Ctrl-Numpad_Divide.

You can then click on the (-) or (+) icon that now appear in the margin next to each function, structure, etc, to expand or collapse it, or use the Folding->Expand all and Folding->Collapse all options from the context sensitive menu (or use keyboard shortcuts Ctrl-Numpad_Multiply and Ctrl-Shift-Numpad_Divide).

Various settings for Folding can also be controlled through

Window -> Preferences -> C/C++ -> Editor -> Folding

Editor templates and Code completion

Within the editor, a number of related pieces of functionality allow you to enter code quickly and easily.

First of all, templates are fragments of code that can be inserted in a semi-automatic manner to ease the entering of repetive code - such as blocks of code for C code structures such as for loops, if-then-else statements and so on.

Secondly, the indexing of your source code that is done by default by the tools, allows for autocompletion of function and variable names. This is known as "content assist".

In addition, the predefined templates are user extensible via

Window -> Preferences -> C/C++ -> Editor -> Templates

Brace matching

The editor can highlight corresponding open and closing braces in a couple of ways.

First of all, if you place the cursor immediately to the right of a brace (either an opening or closing brace), then the editor will display a rectangle around the corresponding brace.

Secondly, if you double click immediately to the right of a brace, then the editor will automatically highlight all of the text between this brace and the corresponding one.

Syntax coloring

Syntax Coloring specifies how your source code is rendered in the editor view, with different colors used for different elements of your source code. The settings used can be modified in:

Window -> Preferences -> C/C++ -> Editor -> Syntax Coloring

Note that general text editor settings such as the background color can be configured in:

Window -> Preferences -> General -> Text Editors

Fonts may be configured in:

Window -> Preferences -> General -> Appearance -> Colors and Fonts

Comment/uncomment block

The editor offers a number of ways of comment in or out one or more lines of text. These can be accessed using the Source entry of the editor context-sensitive menu, or using the following keyboard shortcuts...

Format code

The editor can format your code to match the coding standards in use (Window -> Preferences -> C/C++ -> Code Style). This can automatically deal with layout elements such as indentation and where braces are placed. This can be carried out on the currently selected text using the Source->Format entry of the editor context-sensitive menu, or using the keyboard shortcuts Ctrl-Shift-F. If no text is selected, then the format will take place on the whole of the current file.

Correct Indentation

As you enter code in the editor, it will attempt to automatically indent your code appropriately, based on the code standards in use, and also the layout of the preceeding text. However in some circumstances, for example after manually laying text out, you may end up with incorrect indentation.

This can usually be corrected using the Source->Correct Indentation entry of the editor context-sensitive menu, or using the keyboard shortcuts Ctrl-I. Alternatively use the "Format code" option which will fix other layout issues in addition to indentation.

Insert spaces for tabs in editor

You can configure the IDE so that when editing a file, pressing the TAB key inserts spaces instead of tab characters. To do this go to

Window -> Preferences -> General -> Editors -> Text Editors

and tick the "Insert spaces for tabs" box.

If you tick "Show whitespace characters" you can see whether a tab character or space characters are being inserted when you press the TAB key

Replacing tabs with spaces

To replace existing tabs with spaces throughout the file, open the Code Style preferences:

Window -> Preferences -> C/C++ -> Code Style

Source -> Format

EditorHints (last edited 2012-01-26 15:26:44 by CrSupportAb)