Skip to main content

IAR Embedded Workbench for RL78 5.20

Editing a file

In this section:

The editor window is where you write, view, and modify your source code.

The text editor can perform various kinds of indentation. For assembler source files and plain text files, the editor automatically indents a line to match the previous line.

To indent several lines, select the lines and press the Tab key.

To move a whole block of lines back to the left again, press Shift+Tab.

For C/C++ source files, the editor indents lines according to the syntax of the C/C++ source code. This is performed whenever you:

  • Press the Return key

  • Type any of the special characters {, }, :, and #

  • Have selected one or several lines, and choose the Edit>Auto Indent command.

To enable or disable the indentation:
  1. Choose Tools>Options and select Editor.

  2. Select or deselect the Auto indent option.

    To customize the C/C++ automatic indentation, click the Configure button.

    For more information, see Configure Auto Indent dialog box.

To highlight matching parentheses with a light gray color, place the insertion point next to a parenthesis:

Parentheses_Too64_2.png

The highlight remains in place as long as the insertion point is located next to the parenthesis.

To select all text between the brackets surrounding the insertion point, choose Edit>Match Brackets. Every time you choose Match Brackets (grow) or Match Brackets (shrink) after that, the selection will increase or shrink, respectively, to the next hierarchic pair of brackets.

Note

Both of these functions—automatic matching of corresponding parentheses and selection of text between brackets—apply to (), [], {}, and <> (requires Match All Brackets).

You can split the editor window horizontally into two panes, to look at different parts of the same source file at once, or to move text between two different locations.

To split a window into panes, use the Window>Split command.

To revert to a single pane, double-click the splitter control or drag it to the edge of the window.

To move text within an editor window or to copy between editor windows, select the text and drag it to the new location.

Sections of code can be hidden and displayed using code folding.

To collapse or expand groups of lines, click on the fold points in the fold margin:

CodeFolding_Too65_1.png

The fold point positions are based on the hierarchical structure of the document contents, for example, brace characters in C/C++ or the element hierarchy of an XML file. The Toggle All Folds command (Ctrl+Alt+F) can be used for expanding (or collapsing) all folds in the current editor window. The command is available from the Edit menu and from the context menu in the editor window. You can enable or disable the fold margin from Tools>Options>Editor.

Word completion attempts to complete the word that you have started to type, basing the assumption on the contents of the rest of your document.

To make the editor complete the word that you have started to type, press Ctrl+Alt+Space or choose Complete Word from the context menu. If the suggestion is incorrect, repeat the command to get new suggestions.

By default, the editor automatically suggests completions while you type in a C/C++ source file. You can also open the code completion pop-up window manually by pressing Ctrl+Space.

CodeCompletion_FF90_02.png

To insert a suggestion, either click it or select it with the arrow keys, and press Enter. To close the code completion pop-up window without inserting anything, press Esc.

The suggestions come from the source browse information and require that the source file is part of a project that has been built at least once.

Many—but not all—of the suggested completions are identified by an icon:

EdCodeCompletionClass.png

Class

EdCodeCompletionEnum.png

Enumeration

EdCodeCompletionEnumConstant.png

Enumeration constant

EdCodeCompletionFunction.png

Function

EdCodeCompletionMacro.png

Macro

EdCodeCompletionNamespace.png

Namespace

EdCodeCompletionTypedef.png

Type definition

EdCodeCompletionVariable.png

Variable

To turn off automatic code completion, choose Tools>Options>Editor and deselect the option.

Note

Only active code—code that will be compiled—is suggested.

To make the editor suggest function parameters as tooltip information, start typing the first parenthesis after a function name. A tooltip is also shown when you type a comma in a parameter list.

When there are several overloaded versions of a function, they are all displayed:

ParameterHint_FF908_03.png

Code templates are a method of conveniently inserting frequently used source code sequences, for example for loops and if statements. The code templates are defined in a plain text file. By default, a few example templates are provided. In addition, you can easily add your own code templates.

To set up the use of code templates:
  1. Choose Tools>Options>Editor>Setup Files.

  2. Select or deselect the Use Code Templates option. By default, code templates are enabled.

  3. In the text field, specify which template file you want to use:

    • The default template file

      The original template file CodeTemplates.txt (alternatively CodeTemplates.ENU.txt or CodeTemplates.JPN.txt if you are using an IAR Embedded Workbench that is available in both English and Japanese) is located in a separate directory, see Files for global settings.

      Note that this is a local copy of the file, which means it is safe to modify it if you want.

    • Your own template file

      Note that before you can choose your own template file, you must first have created one. To create your own template file, choose Edit>Code Templates>Edit Templates, add your code templates, and save the file with a new name. The syntax for defining templates is described in the default template file.

    A browse button is available for your convenience.

  4. To use your new templates in your own template file, you must:

    • Delete the filename in the Use Code Templates text box.

    • Deselect the Use Code Templates option and click OK.

    • Restart the IAR Embedded Workbench IDE.

    • Choose Tools>Options>Editor>Setup Files again.

      The default code template file for the selected language version of the IDE should now be displayed in the Use Code Templates text box. Select the checkbox to enable the template.

To insert a code template into your source code:
  1. In the editor window, right-click where you want the template to be inserted and choose Insert Template (Ctrl+Alt+V).

  2. Choose a code template from the menu that appears.

    ListOfCodeTemplates_Mym80_04.png

    If the code template requires any type of field input, as in the for loop example which needs an end value and a count variable, an input dialog box appears.

If the Tools>Options>Editor>Syntax highlighting option is enabled, the IAR Embedded Workbench editor automatically recognizes the syntax of different parts of source code, for example:

  • C and C++ keywords

  • C and C++ comments

  • Assembler directives and comments

  • Preprocessor directives

  • Strings.

The different parts of source code are displayed in different text styles.

To change these styles, choose Tools>Options, and use the Colors and Fonts options. For more information, see Colors and Fonts options.

To define your own set of keywords that should be syntax-colored automatically:
  1. In a text file, list all the keywords that you want to be automatically syntax-colored. Separate each keyword with either a space or a new line.

  2. Choose Tools>Options to open the IDE Options dialog box.

  3. Open the Editor>Setup Files category.

  4. Select the Use Custom Keyword File option and specify your newly created text file. A browse button is available for your convenience.

  5. Open the Colors and Fonts category and click the Colors button. Select User Keyword in the Syntax Coloring list. Specify the color and type style of your choice. For more information, see Colors and Fonts options.

In the editor window, type any of the keywords you listed in your keyword file—see how the keyword is colored according to your specification.

Use the Edit>Navigate>Toggle Bookmark command to add and remove bookmarks. To switch between the marked locations, choose Edit>Navigate>Navigate Next Bookmark or Navigate Previous Bookmark.

The Edit menu provides commands for editing and searching in editor windows, for instance, unlimited undo/redo. You can also find some of these commands on the context menu that appears when you right-click in the editor window. For more information about each command, see Edit menu.

There are also editor shortcut keys for:

  • moving the insertion point

  • scrolling text

  • selecting text.

For more information about these shortcut keys, see Editor shortcut key summary.

To change the default shortcut key bindings, choose Tools>Options, and click the Key Bindings tab. For more information, see Key Bindings options.

The status bar is available by choosing View>Status Bar. For more information, see IAR Embedded Workbench IDE window.