|Physics and Astronomy||
|Physics Home||Study here||Our Teaching||Our Research||Our Centres||News||Work here||EMPS|
Back to top
SPICE 3 User's Manual - Appendix E
History substitution allows you to use words from previous command lines in the command line you are typing. This simplifies spelling corrections and the repetition of complicated commands or arguments. Command lines are saved in the history list, the size of which is controlled by the history variable. The most recent command is retained in any case. A history substitution begins with a ! and may occur anywhere on the command line; history substitutions do not nest.
Input lines containing history substitutions are echoed on the terminal after being expanded, but before any other substitutions take place or the command gets executed. The history list of previous commands can be printed using the interactive interpreter's history command.
An event designator is a reference to a command line entry in the history list.
To re-execute a specific previous command AND make such a substitution, say, re-executing command #6, !:6s/previous_word/replacement/.
A `:' (colon) separates the event specification from the word designator. It can be omitted if the word designator begins with a ^, $, *, - or %. If the word is to be selected from the previous command, the second ! character can be omitted from the event specification. For instance, !!:1 and !:1 both refer to the first word of the previous command, while !!$ and !$ both refer to the last word in the previous command. Word designators include:
After the optional word designator, you can add one of the following modifiers, preceded by a :.
Unless preceded by a g, the modification is applied only to the first string that matches l; an error results if no string matches.
The left-hand side of substitutions are not regular expressions, but character strings. Any character can be used as the delimiter in place of /. A backslash quotes the delimiter character. The character &, in the right hand side, is replaced by the text from the left-hand-side. The & can be quoted with a backslash. A null l uses the previous string either from a l or from a contextual scan string s from !?s. You can omit the rightmost delimiter if a newline immediately follows r; the rightmost ? in a context scan can similarly be omitted.
Without an event specification, a history reference refers either to the previous command, or to a previous history reference on the command line (if any).