EDRUINO - Code completion

Edruino supports code templates / code completion.

Using templates and code completion

There are two ways how to use code templates:

If there is a cursor position symbol (|), the cursor is placed to this position.

If there are more | symbols, you can move to the next cursor position by pressing Ctrl-TAB.

Code completion template file

The code templates for Edruino are stored in the Edruino.templates file in the Edruino folder.

As there is no big syntax correctness veryfying please be carefull if you want to modify the definition file and make a backup before making changes to this file.

The Template file structure

Each template consists of its header and the body.

The template header

The template header is surrounded by square brackets [] and consists of two parts, separated by vertical bar character " | " with spaces on both sides.

Left part is a shortcut which can be used for Autocomplete function by typing the shortcut and pressing the Autocomplete hotkey (Ctrl-space now, might be changed in future).

The right part of the header is a template description - it appears in the template list on the Templates tab.

Please note that there should be a space on both side of the | character !!!

Example of a header line: [fi | int function]

The template body

The body is the source code which is to be inserted in the current cursor position.

It can contain the "|" character as a cursor position after inserting the code.

The template bode can have more "|" symbols for jumping from one insertion point to other. The hotkey for jumping between them is Ctrl-TAB.

Example of a template body:

        int | (void) {
          |;
          return 0;                 
        }
      

Comments

The template definition file can contain comments. They should be placed on its own line and start with // on the first position

In order to avoid evaluating comments inside the template body (inserted code) as a template comment, don't use code comments inside a template body starting on the first line position.

Example of a part of the template definition file

        //Loops
        [fori | for i]
        for (int i=0; i<|; i++)
        {
          |;
        }
        
        [wh | while]
        while (|)
        {
          |;
        }  
        
        [dow | do while]
        do
          {
            |;
          }
        while (|);
        
        //Conditions
        [if | if]
        if (|) 
          {
            |;
          }
        
        [ife | if else]
        if (|) 
          {
            |;
          }
        else
          {
            |
          }
        
      

Invoking code completion

Move cursor to a desired position, type in the code shortcut (e.g. "dow") and press code completion hot key: Ctrl-space bar (in future maybe it'll be changed to Ctrl-J). The template code is inserted in the cursor position and cursor is moved to first "|" position if defined. By pressing Ctrl-TAB, position of the cursor is moved to next "|" marks.

codecompl2.png