The Magma Line Editor

Magma provides a line editor with both Emacs and VI style key bindings. To enable the VI style of key bindings, type

SetViMode(true) : BoolElt ->

and type

SetViMode(false) : BoolElt ->

to revert to the Emacs style of key bindings. By default ViMode is false; that is, the Emacs style is in effect. Many key bindings are the same in both Emacs and VI style. This is because some VI users like to be able to use some Emacs keys (like <Ctrl>-P) as well as the VI command keys. Thus key bindings in Emacs which are not used in VI insert mode can be made common to both.

Contents

Key Bindings (Emacs and VI mode)

<Ctrl>-KEY means hold down the Control key and press KEY.

<Return>
Accept the line and print a new line. This works in any mode.
<Backspace>
<Delete>
Delete the previous character.
<Tab>
Complete the word which the cursor is on or just after. If the word doesn't have a unique completion, it is first expanded up to the common prefix of all the possible completions. An immediately following Tab key will list all of the possible completions. Currently completion occurs for system functions and procedures, parameters, reserved words, and user identifiers.
<Ctrl>-A
Move to the beginning of the line ("alpha" = "beginning").
<Ctrl>-B
Move back a character ("back").
<Ctrl>-C
Abort the current line and start a new line.
<Ctrl>-D
On an empty line, send a EOF character (i.e., exit at the top level of the command interpreter). If at end of line, list the completions. Otherwise, delete the character under the cursor ("delete").
<Ctrl>-E
Move to the end of the line ("end").
<Ctrl>-F
Move forward a character ("forward").
<Ctrl>-H
Same as Backspace.
<Ctrl>-I
Same as Tab.
<Ctrl>-J
Same as Return.
<Ctrl>-K
Delete all characters from the cursor to the end of the line ("kill").
<Ctrl>-L
Redraw the line on a new line (helpful if the screen gets wrecked by programs like "write", etc.).
<Ctrl>-M
Same as <Return>.
<Ctrl>-N
Go forward a line in the history buffer ("next"). If the cursor is not at the beginning of the line, go forward to the first following line which starts with the same string (ignoring spaces iff the ignore spaces option is on --- see SetIgnoreSpaces) as the string consisting of all the characters before the cursor. Also, if <Ctrl>-N is typed initially at a new line and the last line entered was actually a recall of a preceding line, then the next line after that is entered into the current buffer. Thus to repeat a sequence of lines (with minor modifications perhaps to each), then one only needs to go back to the first line with <Ctrl>-P (see below), press <Return>, then successively press <Ctrl>-N followed by <Return> for each line.
<Ctrl>-P
Go back a line in the history buffer ("previous"). If the cursor is not at the beginning of the line, go back to the first preceding line which starts with the same string (ignoring spaces iff the ignore spaces option is on --- see SetIgnoreSpaces) as the string consisting of all the characters before the cursor. For example, typing at a new line x:= and then <Ctrl>-P will go back to the last line which assigned x (if a line begins with, say, x :=, it will also be taken).
<Ctrl>-U
Clear the whole of the current line.
<Ctrl>-V<char>
Insert the following character literally.
<Ctrl>-W
Delete the previous word.
<Ctrl>-X
Same as <Ctrl>-U.
<Ctrl>-Y
Insert the contents of the yank-buffer before the character under the cursor.
<Ctrl>-Z
Stop Magma.
<Ctrl>-_
Undo the last change.
<Ctrl>-\
Immediately quit Magma.

On most systems the arrow keys also have the obvious meaning.

Key Bindings in Emacs mode only

<Meta>-KEY means press the Meta key and then KEY. (At the moment, the Meta key is only the Esc key.)

<Meta>-b
<Meta>-B
Move back a word ("Back").
<Meta>-f
<Meta>-F
Move forward a word ("Forward").

Key Bindings in VI mode only

In the VI mode, the line editor can also be in two modes: the insert mode and the command mode. When in the insert mode, any non-control character is inserted at the current cursor position. The command mode is then entered by typing the Esc key. In the command mode, various commands are given a range giving the extent to which they are performed. The following ranges are available:

0
Move to the beginning of the line.
$
Move to the end of the line.
<Ctrl>-space
Move to the first non-space character of the line.
%
Move to the matching bracket. (Bracket characters are (, ), [, ], {, }, <, and >.)
;
Move to the next character. (See `F', `f', `T', and `t'.)
,
Move to the previous character. (See `F', `f', `T', and `t'.)
B
Move back a space-separated word ("Back").
b
Move back a word ("back").
E
Move forward to the end of the space-separated word ("End").
e
Move forward to the end of the word ("end").
F<char>
Move back to the first occurrence of <char>.
f<char>
Move forward to the first occurrence of <char>.
h
H
Move back a character (<Ctrl>-H = Backspace).
l
L
Move back a character (<Ctrl>-L = forward on some keyboards).
T<char>
Move back to just after the first occurrence of <char>.
t<char>
Move forward to just before the first occurrence of <char>.
w
Move forward a space-separated word ("Word").
W
Move forward a word ("word").

Any range may be preceded by a number to multiply to indicate how many times the operation is done. The VI-mode also provides the yank-buffer, which contains characters which are deleted or "yanked" -- see below.

The following keys are also available in command mode:

A
Move to the end of the line and change to insert mode ("Append").
a
Move forward a character (if not already at the end of the line) and change to insert mode ("append").
C
Delete all the characters to the end of line and change to insert mode ("Change").
c range
Delete all the characters to the specified range and change to insert mode ("change").
D
Delete all the characters to the end of line ("Delete").
d range
Delete all the characters to the specified range ("delete").
I
Move to the first non-space character in the line and change to insert mode ("Insert").
i
Change to insert mode ("insert").
j
Go forward a line in the history buffer (same as <Ctrl>-N).
k
Go back a line in the history buffer (same as <Ctrl>-P).
P
Insert the contents of the yank-buffer before the character under the cursor.
p
Insert the contents of the yank-buffer before the character after the cursor.
R
Enter over-type mode: typed characters replace the old characters under the cursor without insertion. Pressing Esc returns to the command mode.
r<char>
Replace the character the cursor is over with <char>.
S
Delete the whole line and change to insert mode ("Substitute").
s
Delete the current character and change to insert mode ("substitute").
U
u
Undo the last change.
X
Delete the character to the left of the cursor.
x
Delete the character under the cursor.
Y
"Yank" the whole line - i.e., copy the whole line into the yank-buffer ("Yank").
y range
Copy all characters from the cursor to the specified range into the yank-buffer ("yank").
V2.28, 13 July 2023