<!-- Forthmacs Formatter generated HTML V.2 output -->
<html>
<head>
<title>Typing Forth Command Lines</title>
</head>
<body>
<h1>Typing Forth Command Lines</h1>
<hr>
<p>
This chapter describes the editing facilities that are available when you are 
typing command lines to RISC OS Forthmacs.  These facilities are much more 
powerful than those of most other systems.  Study this carefully, and it will 
save you a great deal of typing in the future.  
<p>
<p>
<p><pre>
    Quick Reference Chart:
        Moving:         Character       Word            Line
            backward:   left-arrow      ESC-b           ^A
                        or ^B   
            forward:    right-arrow     ESC-f           ^E
                        or ^F
        Erasing:        Character       Word            Line
</pre><p>
<p>
<p><pre>
            backward:   ^H              ESC-h   
                        or Backspace    or ^W   
            forward:    ^D              ESC-d           ^K
                        or Delete
            entire line:                                ^U
</pre><p>
<p>
<p><pre>
        Others:
            previous command            up-arrow  or  ^P
            next command                down-arrow  or  ^N
</pre><p>
<p>
<p><pre>
            complete word               ^C
            show matches                ^S
</pre><p>
<p>
<p><pre>
            retype line                 ^L
            quote next character        ^Q
</pre><p>
<p>
<p>
<h2>Typing Forth Command Lines</h2>
<p>
<p>
<h2>Notation</h2>
<p>
<p><pre>
  ^B      hold down the Control key and simultaneously type the b key.
  ESC-b   first type the Esc key, release it, and then type the b key.
  ^X^C    first press ^X, release it, and then press ^C
</pre><p>
<p>
Note that for Control, two keys are typed at the same time, whereas for Esc, the 
Esc key is first typed and released, then the other key is typed.  
<p>
<p>
<h2>Moving</h2>
<p>
<p><pre>
  left-arrow   or  ^B     Backs up one character without erasing
  right-arrow  or  ^F     Moves forward one character without erasing
  ESC-b                   Backs up one word without erasing
  ESC-f                   Moves forward one word without erasing
  ^A                      Moves to the beginning of the line
  ^E                      Moves to the end of the line
</pre><p>
<p>
<p>
<h2>Erasing</h2>
<p>
<p><pre>
  Backspace or ^H         Erases character to the left of the cursor
  Delete or ^D            Erases character at the cursor
  ESC-h                   Erases the word to the left of the cursor
  ESC-d                   Erases the word to the right of the cursor
  ^K                      Erases from the cursor to the end of the line
</pre><p>
<p>
<p>
<h2>History</h2>
<p>
RISC OS Forthmacs remembers the last 8 lines you typed, so you can easily 
<p>
<p><pre>
  repeat or modify previously-typed commands.
  up-arrow    or ^P       Steps backward through the list of
                          previous commands.
  down-arrow  or ^N       Steps forward through the list of
                          previous commands.
</pre><p>
<p>
<p>
<h2>Command Completion</h2>
<p>
When you are typing a Forth word, it is not always necessary to type the whole 
word.  If you type the first few characters of the word, then type ^C (i.e.  
hold down the Control key and type the C), Forth will try to finish the word for 
you by looking in its dictionary for words which start with the characters you 
have typed.  If there is only one possible word, Forth will complete the word 
for you.  
<p>
Sometimes Forth will be unable to finish the word.  If there are no words in the 
Forth dictionary which start with the characters you have already typed, Forth 
will remove characters from the end until the characters that are left start 
some word in the dictionary.  If there are several words which start with your 
characters, Forth will complete the word as far as it can.  In either case, you 
can then type some more characters to further specify the desired word, then try 
^C again.  
<p>
<p><pre>
  ^C            Forth attempts to complete the word you have started
  ^S            Shows a list of all the words which start with the
                characters you have typed.
</pre><p>
<p>
<p>
<h2>Miscellaneous</h2>
<p>
<p><pre>
  ^L              Retypes the current line.
  ^Q              The next character typed (usually a control
                  character) is inserted into the line being typed,
                  instead of being treated as an editing command.
</pre><p>
<p>
<p><pre>
  ^X^C            Quit Forthmacs at once
</pre><p>
<p>
<p>
<h2>Mnemonics</h2>
<p>
To make it easier to remember the control commands, here are some mnemonics: 
<p>
<p><pre>
  ^F   ESC-f      Forward character or word
  ^B   ESC-b      Backward character or word
  ^E              End of line
  ^D   ESC-d      Delete character or word
  ^K              Kill rest of line
  ^P              Previous line
  ^N              Next line
  ^Q              Quote next character
</pre><p>
<p>
<p>
<h2>Tips</h2>
<p>
To delete the entire line, type ^A followed by ^K.  It is not necessary to 
release the Control key between the typing of the A and the typing of the K.  
<p>
Practice using the history mechanism (^P and ^N).  Forth commands are frequently 
repeated, and the history feature can save you much typing.  
<p>
The "show matches" command (^S) can be used to find all the Forth words which 
start with a particular string of characters.  Just type that string of 
characters then type ^S.  (There is a Forth command <code><A href="_smal_BW#2FE">sifting</A></code> 
that will find all the words which contain a particular string anywhere in the 
name, not just at the start as in ^S.  <code><A href="_smal_BW#2FE">sifting</A></code> 
is described in the master glossary.  
<p>
Try to train your fingers to type ^F, ^B, ^A, ^E, and ^D without using your 
right hand.  This can make editing very fast because you don't have to move your 
hands very far, and it is relatively easy to type these combinations without 
looking at your fingers.  
<p>
Why do many functions have two different key assignments? Some people prefer to 
use the arrow keys because they are easier to remember.  Others prefer to use 
the ^ keys because they can be typed without moving the hands from the home keys 
on the keyboard.  
<p>
<p>
<p>
<p>
<h2>For Experts</h2>
<p>
If you do not like the assignment of functions to keys (for instance you might 
prefer to use ^S and ^D to move forward and backward, as in Wordstar), you can 
easily change the assignments.  The vocabulary <code><A href="_smal_BQ#268">keys-forth</A></code> 
contains a colon definition or alias for each key assignment.  These assignments 
may be redefined using normal colon definitions.  
<p>
However, note that the existing key assignments are the same as the ones in the 
Emacs editor.  The Emacs key assignments cannot be easily changed, so if you 
change the assignments in <code><A href="_smal_BQ#268">keys-forth</A></code> you 
will make them different from the ones in Emacs.  
<p>
</body>
</html>
