Skip to content

Usage

Running Code

When the Elk-program is executed without any command line arguments, it drops the user into the interactive shell mode. This allows you to type commands and get results immediately, like you would expect from a shell program. When a file path is given as a command line argument, the code in that file is evaluated.

elk
elk someFile.elk
elk someFile.elk

Interactive Mode

An interactive shell session can be started by running elk without any command line arguments. The following shortcuts are available:

Key CombinationAction
Left Arrow, Ctrl+BMove cursor left
Right Arrow, Ctrl+FMove cursor right, Apply hint
Up Arrow, Ctrl+PNext item in history (that starts with the text currently in the prompt, if any)
Down Arrow, Ctrl+NPrevious item in history
Ctrl+Left ArrowMove one word to the left
Ctrl+Right Arrowmove one word to the right
Home, Ctrl+AMove to the start of the line
End, Ctrl+EMove to the end of the line
BackspaceRemove the character to the left
DeleteRemove the character to the right
Ctrl+Backspace, Ctrl+WRemove the word to the left
Ctrl+LClear the console
Ctrl+URemove everything to the left
Ctrl+RSearch in history
TabNext tab completion
Shift+TabPrevious tab completion

Multi-Line Input

There are several ways to insert a new line into the command line prompt without submitting:

  • Leave a brace unclosed and press enter, eg. if x {
  • Leave a string literal unclosed and press enter, eg. "hello world
  • Press enter after typing a |symbol (this will also put the pipe on a new line)
  • Press enter after typing a \ symbol