Keyword completion customization

This document describes the syntax used to customize keyword automatic completion.
Four strings are used to define the completion of a keyword. The rules are the same for all of them:

  • These strings will be inserted right after the keyword. The key that triggers the automatic completion will not be taken into account, i.e. no space or "new line" character will be inserted even though you press Space or Return. The strings should therefore begin with a space or a "new line" character (see below for "newline").
  • Two reserved words will allow you to position the cursor and to indent the text properly. Insert the word $cursor$ in the string where you want the cursor to be moved once the completion is finished. Insert the word $indent$ where you want to copy as many blank spaces as there were on the line where the keyword was typed.
  • Three special characters are available:
    • %N represents the new line character.
    • %T represents the tabulation
    • %B represents the back space


Examples :

1) You want the lines of code :

if next_line_of_code

to become:

if <cursor here> then <one more tabulation> end next_line_of_code

as you press Space just after typing if.

To make this happen, you should define the "Customized auto complete (Space after keyword was typed)" string for if as :

$cursor$ then%N$indent$%T%N$indent$end

First, EiffelStudio editor has to insert a blank space after if. The string begins therefore by a blank space.
Then, $cursor$ tells EiffelStudio to move the cursor to this position after the completion.
then is inserted after the cursor position.
%N indicates that you want to insert a new line after then.
$indent$%T means that this line is filled with as many blank spaces as there are before if plus a tabulation.
Another line is inserted with %N.
Then $indent$end means that end will be inserted in this new line with the same indentation as if.

2) You want the lines of code :

end next_line_of_code

to become:

end next_line_of_code

as you press Return just after typing end.

To make this happen, you should define the "Customized auto complete (Return after keyword was typed)" string for end as :

%B%B%B%Bend%N$indent$%B$cursor$

The four %B will remove end plus one character before end (the tabulation character).
end will be inserted at this new position.
%N indicates that you want to insert a new line.
$indent$%B$cursor$ means that the cursor will be moved to the end of the line where one less blank space than before the original end will have been inserted.

Note: EiffelStudio editor can insert spaces instead of tabulation when you use special character %T. This is set in another section of the preferences .

See Also:
Keywords automatic completion preferences
Default values for keyword completion preferences