Elan code editor

To open the Elan code editor in a new browser tab, click https://elan-lang.org

Click on the File menu and choose New.

You will see the Elan version and the prompt showing all the Global keywords:

# 3dc077f604fb3b9338c8e0104060503ae108013df97a7fc82066915f81a30804 Elan 1.2.6 guest default_profile new code
main procedure function test constant enum record class abstract interface #

Press m on your keyboard, and the main routine will be entered into your code, displaying both a prompt for all the keywords you can use within main and a new code prompt at the global level.

+main new code
call each for if let print repeat set throw try variable while #
end main
new code

The prompt within main is already selected, so you can type, say, p and a print instruction will be entered with a field soliciting an expression, into which you can type (for example) a quoted string. The field will then have a green background indicating that the instruction is valid.

+main print new code
call each for if let print repeat set throw try variable while #
end main

The code shown in the editor has three types:

- Instructions
  All instructions begin with a dark blue keyword (here let): let name be "Alice"
- Comments
  Comments start with a hash # which is optionally followed by text: # A program to investigate the Collatz Conjecture The first comment in a file (which shows the Elan version: see 'Start coding' above) is automatically created and cannot be edited, deleted, or moved.
- new code prompts
  - A new code prompt that has not been clicked on looks like this: new code
  - When selected, a new code prompt displays the keywords that are valid in the context, like this: new code
    call each for if let print repeat set throw try variable while #
    Pressing the initial letter (in some cases two) of any of the keywords shown will enter it.
- Comments and new code prompts are not instructions, but they are treated like instructions by the editor.

An instruction consists of keywords that cannot be edited or deleted, and fields that you may fill with values. See an example in 'A first instruction' above.

A selected field has a thin black border and a background colour that indicates its status:

- Grey: optional – the field may be left empty
- Green: valid – the current contents are accepted in the field
- Amber: incomplete – more text is needed to make it valid
- Red: invalid – the current contents are unusable: if you are entering new code and the field turns red, it is best to press Backspace until it turns green or amber again

To cycle through the fields within an instruction (and back to the instruction keyword) use Tab (forwards) or Shift+Tab (backwards).

A field open for editing has the text cursor initially at the right hand end: you move around it using left and right cursor keys in the usual way.

Click on:

- either the first keyword of the instruction
- or the corresponding instruction number to the right of it

To select an instruction (single or compound) click on its keyword.

If the current selection is a field press Tab until the whole instruction is selected.

If an instruction is already selected, then you can use:

- ⇩ (Down cursor key) to select the next instruction
- ⇧ (Up cursor key) to select the previous peer-level instruction
- Home to select the first peer-level instruction
- End to select the last peer-level instruction

where peer-level means at the same level of indentation and so within the same frame.

- A single selected instruction looks like this: let name be "Alice"
- A selected compound instruction looks like this: let names be ["Alice", "Bob"] +each n in names print n end each

  where the blue highlight shows the selected compound instruction's frame with its content indented. The final line of a compound instruction starts with end.

To move to selecting a different frame, use:

- ⇦ (Left cursor key) to move up to the frame that contains the selected instruction (i.e. one level above peer) if any.
  Global instructions start at the left hand edge of the editor and are not themselves contained in any higher instruction.
- ⇨ (Right cursor key) to move down into the first instruction contained in the selected keyword (i.e. one level below peer) if any.

To select multiple consecutive instructions,

- either press Shift while clicking on their keywords to highlight them
- or press:
  - Shift+⇩ (Down cursor key) to add the next instruction to the selection
  - Shift+⇧ (Up cursor key) to add the previous peer-level instruction to the selection

let name be "Alice" print name

- To insert code at a new code prompt, select it and type the initial letter of a keyword.
- To insert new code next to a selected instruction::
  - either press Enter to insert code below it
  - or press Shift+Enter to insert code above it

To delete one or more instructions (all at the same level), select either one instruction or a group of consecutive instructions,
then press Ctrl+d or Ctrl+Delete, or cut them to the clipboard with Ctrl+x.

To move one or more instructions, select them and cut them to the clipboard with Ctrl+x then, at a new code prompt, paste them in with Ctrl+v.

Click the new code prompt to change it to the prompt of valid keywords in the context.

If none is visible, select an instruction (or frame) and press Enter to insert new code below it.

If you wish to remove all new code prompts, press Alt+t or use the menu item trim.

To make the logical structure of your program, or parts of it, more easily seen, you may collapse any Global instruction (e.g. main, function) and any compound statement by selecting it and then double-clicking on its initial keyword. The instruction will now be displayed only as a white on green plus sign to the left of its first line:

+main

You restore the instruction by double clicking on the plus sign.

Go to the top