RISC OS 3.7 User Guide


18 Edit


Edit is a text editor which you can use to create and edit plain text, and to generate simple text documents and command scripts.

Edit is also a BASIC program editor. It converts BASIC programs into text format for editing, and then converts them back again when they are saved.

Although Edit does have some sophisticated features for handling text, it has not been designed as a word processor; word processors offer facilities for pagination and page layout control as well as paragraph styles and printable fonts.

Starting Edit

Edit is in the Apps icon bar directory display. To start Edit, double-click on the !Edit application icon. The application icon appears on the icon bar.

Displaying an Edit file

To display an existing text file, just double-click on it, or drag the file's icon to the Edit icon on the bar.

Displaying other file types

To display any other file type, drag the file icon to the Edit icon on the bar, or hold down Shift and double-click on it. BASIC files are displayed as text.

Opening a new text document

Click on the Edit icon on the icon bar to open a new document.

Creating other file types

You can open new windows for other specific types of file: Text, BASIC, Obey and Command files. To do this, choose Create from the Edit icon bar menu and specify the file type you want. Alternatively you can type in a file type of your own choice at the bottom of the Create menu.

Typing in text

When you first open a new Edit window, a red I-shaped bar - the caret - appears at the top left of the window. This is where text appears when you start typing. You can open more than one Edit window (see Other features of Edit on page 278) but only one (the current window) has the caret in it. This window is said to have the input focus, and is also identified by its cream rather than grey title bar. You can only type in the window which has the input focus.

If you type in some text without pressing Return at all, the window scrolls sideways (if your Edit window is smaller than your screen). You can break your text into lines by pressing Return. Alternatively, click on the Toggle size icon to extend the window to the full size and avoid having to scroll sideways.

As you type, notice that Edit fills the current line and then carries on to the next line, often breaking words in the middle. By default, it doesn't automatically enter formatting characters such as newline, as these might create problems in scripts and programs, and in transferring text into other editors. Formatting text on page 273 tells you how to set wordwrap and other formatting options if you want them.

Editing text

Here are some basic techniques for entering and deleting text:

To:

There are quicker ways of deleting a lot of text - see page 264.

Selecting text

You can edit more than one character at a time by defining a block of text you want to edit, then cutting, copying or pasting the whole block. A block of text can be one or two characters, a word, a line, a paragraph or the whole document:

To:

Block editing operations

First select a block of text as described in the previous section

To:

Undoing changes

If you make a mistake or have second thoughts about an edit, choose Edit/ Undo (or press F8) to step back through your most recent changes. The number of changes you can reverse in this way varies according to the operations involved.

Edit/Redo (or the F9 key) allows you to remake the changes you reversed with Undo.

Finding and replacing text

Edit has a very sophisticated find and replace function, to enable you to find words or characters in a document and replace them by others if you wish.

To find a particular word or character (the 'target string') position the caret at the start of the file before choosing Find. The target string may be any combination of words, numbers, letters, spaces or other non-printing characters.

Searching for a string

1 Choose Edit/Find:

2 Type in the string you wish to find and click on Go.

(If you've already tried to find the string once and want to search for it again, click on Previous.)

If the string is not located, the message Not found is displayed.

If it is found, the Text found dialogue box appears:

3 Click on Continue to look for the next instance of the string.

Other Find and Replace options

To:

Making searches case sensitive

By default, Find text makes no distinction between upper and lower case: it will find for example HELLO, hello, or HeLLo. If you click on Case sensitive, however, it will find only those instances which match exactly in case.

Using magic characters

You can also use find and replace special, or 'magic' characters. Click on Magic characters (or press F5) in the Find dialogue box and a list of them will be displayed in the lower half of the dialogue box:

Magic characters start with a \ character, and you type them into the Find and Replace with boxes exactly as shown:

Functions and their magic characters:

Using wildcarded expressions

There is also a facility for specifying wildcarded expressions in search strings. Click on Wildcarded expressions in the Find dialogue box to display the ones you can use:

Click on the wildcard character you wish to enter and it is copied into the text box at the caret.

Functions and the wildcard symbol to click on:

The full power of the wildcard facility can be illustrated by a few examples:

Reading in text from another file

If you want to add all the text from another file into the current file:

1 Position the caret at the point where the inserted text is to appear.

2 Open the directory display for the source file, and drag its icon into the destination text window.

The entire contents of the source file is then copied into the destination file, starting at the caret position. The caret appears at the end of the text you have inserted.

There are two ways of reading in part of one file into another:

Formatting text

Formatting describes how the text in Edit is arranged on the page.

Before you can use these features, click in the Edit window to get the input focus (the title bar will turn yellow).

To:

Indenting text

You can indent a selected block of text in Edit. The indent is defined in character spaces. You can indent using just spaces, or add a text prefix to the beginning of each line of a block.

To indent a selected block of text, choose Edit/Select/Indent:

You can then type in one of three different types of indent:

Using tabs

Tabs in Edit are designed to work with fixed-pitch fonts, such as the System font. If you use tabs in Edit with proportionally-spaced fonts (such as Trinity, for example), tables will not line up properly.

Laying out tables with irregular columns

Lay out the first line of a table (the headings, for example) using spaces between each column. On the next line, press Tab and the cursor will jump to each column in turn:

Laying out tables with regular columns

Pressing Tab with Misc/Column tabs switched on sets tabs every eight spaces.

Converting tab characters to column tabs

You may have text imported from a word processor, which has tab characters ([09]) embedded in it. These can be expanded into Edit regular column tabs (eight spaces for each tab character) by choosing Edit/Expand tabs.

The text will be reformatted so that each tab character is replaced by eight spaces.

Changing the display font

You can display Edit files using any available desktop font:

To:

Note: Font information is not saved with the Edit file, so does not print. You can only have one style of text at a time in each Edit document.

Exporting (saving) text

The Save menu allows you to save a complete file; you can also save part of a file.

To:

Printing Edit files

There are several ways of printing an Edit file; to use them, you first need to load the Printers application (refer to Printing your files on page 143).

To:

Note: Edit files are always printed out using the printer's default font. This overrides any screen font (chosen from the Edit/Display/Font menu).

Other features of Edit

This section describes some features of Edit that you won't need to use very often.

To:

Writing and editing BASIC programs

Edit allows you to write BASIC programs, converting the Text files produced in Edit to tokenised BASIC files. A tokenised file is one where BASIC keywords are replaced by seldom-used ASCII characters, to make the program smaller and faster in execution.

Writing a new program

To write a new program, choose Create/BASIC from Edit's icon bar menu. You can type your program directly into an Edit window. There is no need to include line numbers, as Edit will insert them for you when you save the file. Press Return at the end of the last line of the program.

Editing an existing program

To use Edit for working on an existing BASIC program, simply drag the program's icon from its directory onto the Edit icon on the icon bar, or Shift double-click on its icon.

Line numbers

By default, line numbers will be stripped when a BASIC file is loaded. To turn this option on or off, choose Strip line numbers from the Edit icon bar menu. If a reference to a line is found, an error box will appear.

Line numbers are added when a BASIC file is saved. Use Line number increment from the Edit icon bar menu to set the number increment between successive lines in the program.

Converting to a tokenised file

A tokenised file saves space: top-bit-set characters and control characters (non-printing characters) are used to stand for the BASIC keywords. So, for example, the Hex character E3 stands for the keyword FOR.

Converting a text file to a tokenised file is usually quite straightforward. If there are no line numbers, by default Edit will start at 10 and increment by 10. If line numbers are supplied, these are used as a basis for any lines without line numbers.

Warnings

If there are line numbers, Edit will not sort them into ascending sequence and the resulting BASIC program may behave strangely.

If your code is incomplete, Edit will warn you about the following problems:

In all cases Edit will also quote the offending line number. After you have clicked on OK, the tokenising continues.

Attempts to tokenise a crunched program (e.g. one with the spaces removed) will generally result in a non-functioning program.

Printing a BASIC program

If you have Edit running, you can print a BASIC program on paper by dragging its icon onto a printer driver icon. Edit will perform the conversion to allow the program to be printed.

Quitting Edit

Choose Quit from the Edit icon bar menu to stop Edit and remove it from the computer's memory. A dialogue box may be displayed, warning you if there are any current files you have not saved.

Saving Edit features in a Desktop boot file

You may wish to change some aspects of the way new Edit windows appear. For example, a new window normally opens using black text on a white background, but you may prefer to have blue text on a red background ready to use each time you start Edit.

You can set features of this type by setting up Edit just as you wish to use it, then save these features by creating a Desktop boot file. Instructions on how to create a Desktop boot file are given in Configuring applications on page 427.

Keystroke equivalents

On occasions, it can be quicker when you are working in Edit to use the keyboard instead of the mouse, especially once you are familiar with the program.

When editing

Actions and keys to press:

In the Select menu

Actions and keys to press:

In the Edit menu

Actions and keys to press:

In the Find menu

Note: these keystroke definitions only come into play once the Find dialogue box has been displayed (e.g. by typing F4).

Actions and keys to press:

File options

Actions and keys to press:


RISC OS 3.7 User Guide - 22 JAN 1997