13.2 Interactive Editing

It is possible when working interactively to edit any REDUCE input that comes from the user’s terminal, and also some user-defined procedure definitions. At the top level, one can access any previous command string by the command ed(n), where n is the desired command number as prompted by the system in interactive mode. ED; (i.e. no argument) accesses the previous command.

After ED has been called, you can now edit the displayed string using a string editor with the following commands:


move pointer to beginning


replace next character by character


delete next character


end editing and reread text


move pointer to next occurrence of character


insert string in front of pointer


delete all characters until character


print string from current pointer


give up with error exit


search for first occurrence of string, positioning pointer just before it

  space or X

move pointer right one character.

The above table can be displayed online by typing a question mark followed by a carriage return to the editor. The editor prompts with an angle bracket. Commands can be combined on a single line, and all command sequences must be followed by a carriage return to become effective.

Thus, to change the command x := a+1; to x := a+2; and cause it to be executed, the following edit command sequence could be used:


The interactive editor may also be used to edit a user-defined procedure that has not been compiled. To do this, one says:

editdef id;

where id is the name of the procedure. The procedure definition will then be displayed in editing mode, and may then be edited and redefined on exiting from the editor.

Some versions of REDUCE now include input editing that uses the capabilities of modern window systems. Please consult your system dependent documentation to see if this is possible. Such editing techniques are usually much easier to use then ED or EDITDEF.