|
Efficient Browsing and Editing |
In Red, there are two basic alternatives to move the cursor: the mouse and the keyboard. Using the mouse to move the cursor or to change the view is fairly straightforward, but nevertheless briefly explained in the section Using the mouse. This section explains the use of keys to move the cursor and the view and edit the text.
Two groups of commands are available for wandering through a text: commands to move the cursor (the mark where text is entered) and commands to move the view. The view is the window showing the section of the text you can see at any time. If I say "the view is moved down", what it means is, that the edit window will display a section of the text further down from before.
The cursor and the view are losely connected. The cursor never leaves the view. So similar effects can often be achieved with cursor and view commands. Moving the cursor up in the text will take the view with it, and vice versa. But, as you will see, there are some differences.
The general rules are: When the cursor leaves the screen, the view is adjusted to show the cursor in the middle of the screen. When the view is changed so that the cursor would disappear from the screen, the cursor is set to the very top or bottom of the view, depending on where it was before.
Almost all of the cursor and view movements can be done with the cursor block and the modifier keys. In addition, some editing functions (deleting and cutting text) can be done with the cursor keys as well. Getting familiar with the functions on the cursor keys is probably one of the most important things for efficient editing.
Here is a table listing the functions bound to the cursor keys:
shift | alt | shift-alt | ctrl | shift-ctrl | alt-ctrl | ||
---|---|---|---|---|---|---|---|
![]() | forward- char | end-of- line | forward- word | delete-char | cut-to- end-of-line | cut-to- end-of-word | |
![]() | backward- char | beginning- of-line | backward- word | backward- delete-char | cut-line | cut-word | |
![]() | previous- line | scroll- line-up | previous- page | scroll-half- page-up | beginning- of-text | ||
![]() | next-line | scroll- line-down | next- page | scroll-half- page-down | end-of-text |
Apart from the cursor keys, there are some other keys that move the cursor and perform basic editing functions. They are listed in the following table.
Key Name | Function called | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Insert paste | Backspace | backward-delete-char | Delete | delete-char | Home | beginning-of-text | End | end-of-text | Page up | previous-page | Page down | next-page | F2 | select-line | F3 | paste | F4 | cut-line | F12 | undo | |
Red provides some functions for handling lines. They are select-line, cut-line, and paste and are by default bound to the function keys F2, F3 and F4 (see table above).
Using these three keys, lines or groups of lines can be removed, copied, or moved very quickly. When selecting lines, the first call to select-line will select the current line. Every subsequent call will add the next line to the selection. The selected text is automatically put into the paste buffer (as it is the convention for X-Windows applications). No explicit copy operation is needed. (For more details, see Cut, Copy and Paste.)
Similarly, when cutting lines (using cut-line), lines are collected in the paste buffer as long as no other functions are called inbetween. (That means: when doing a cut, then moving the cursor, then cut again, the second cut will replace the first in the paste buffer. But when the cut-functions are called consecutively, the second cut is added to the paste buffer.) This way, a group of lines can be moved (cut and pasted) quickly.