REDUCE

13.3 Interactive Editing: ed, editdef

It is possible when working interactively to edit any REDUCE input that comes from your terminal, and also some user-defined procedure definitions. At the top level, you 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. The command ed (with 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:

  b

move pointer to beginning

  c\(\langle \)character\(\rangle \)

replace next character by \(\langle \)character\(\rangle \)

  d

delete next character

  e

end editing and reread text

  f\(\langle \)character\(\rangle \)

move pointer to next occurrence of
\(\langle \)character\(\rangle \)

  
  i\(\langle \)string\(\rangle \)\(\langle \)escape\(\rangle \)

insert \(\langle \)string\(\rangle \) in front of pointer

  k\(\langle \)character\(\rangle \)

delete all characters until \(\langle \)character\(\rangle \)

  p

print string from current pointer

  q

give up with error exit

  s\(\langle \)string\(\rangle \)\(\langle \)escape\(\rangle \)

search for first occurrence of \(\langle \)string\(\rangle \),
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:

        f1c2e<return>

You can also use the interactive editor to edit a user-defined procedure that has not been compiled. To do this, use:

editdef \(\langle \)id\(\rangle \);

where \(\langle \)id\(\rangle \) 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 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.


Hosted by Download REDUCE Powered by MathJax