Zap Documentation      Latest release     
ZapRedraw      Contact      Download     

Previous | Contents | Index | Next

Chapter 6: Advanced editing

Now we discuss some advanced editing options - features that you can turn on and off. You can set up each individual mode so that it has whichever of these options turned on or off that you want; see section 12.2.1 for more information.

6.1 Auto indenting

Suppose you are typing a list in which each of the entries itself might be a list. To make things clearer, you would probably want to indent each list, looking something like:

 First list, first entry
 First list, second entry - this is a list too!
   Second list, first entry
   Second list, second entry
 First list, third entry

If the lists were long, you could spend ages pressing Space or Tab to indent your lists correctly - but fortunately Zap can help you here. With auto indent mode turned on (as it is by default in Text and many other modes), Zap will match the indent of the line above whenever you press Return.

(Some modes, such as the C, C++ and Java programming modes, help you even more by automatically indenting to match a standard programming style; see section 10.5 for more information.)

Pressing cReturn breaks the line without indenting, even when auto indent mode is turned on.

6.2 Tabbing

Tabbing in Zap means two things: firstly, the action of the Tab key, and second how it displays tabs embedded in the file you are working on. We'll deal with each of these individually.

6.2.1 Tab editing

What happens when you press the Tab key is determined by the current tab entry mode, which is configured from the Edit->Tab mode submenu. Zap has three tab entry modes:

In the last two cases, as many tab characters are inserted as possible before using spaces. If you wish to use only spaces, turn on the As spaces option, in the Edit->Tab mode submenu.

You can use sTab to switch between Unix and As above tab entry modes.

6.2.2 Tab display

The standard tab character is taken to be ASCII 9, but this can be changed from the Display->Tabs->Tab char submenu. Here you can also configure how the tab character is displayed. Note that unless you choose 'None', the tab spacing will be to the next column of eight characters. (This is one of the main things which isn't configurable, partly because it would considerably slow down Zap's redraw system, but also because that's what tab characters mean, Bill Gates notwithstanding.)

The options are:

If you want nothing to ever act or be displayed like a tab, set the tab character to the same as the end of line character - see section 7.1.

6.3 Wrapping and formatting your text

Zap has a number of different options for dealing with files where you are editing lines which are longer than the current window is wide. Some of these can work together (for instance window wrap and soft wrap together is a very useful combination); some of them are mutually exclusive.

Not all of these options are available in all modes.

6.3.1 Window wrap

This performs the same action as the option with the same name in Edit: lines which are longer than will fit into the window are wrapped onto the next line. This happens dynamically as the window is resized, so there are never any parts of the text which are not visible at the sides of the screen. (Compare this with having all special wrap modes turned off, where lines which are longer than will fit inside the window extent are wrapped onto the next line - if you resize the window, you will often obscure the ends of long lines and have to scroll to view and edit them.)

Because only the visible area of the window is used, the horizontal scroll bar cannot be dragged, although it still indicates the true maximum window width. (In RISC OS 3, you can Adjust drag the horizontal scroll bar, but it will only allow you to scroll the window vertically.)

Window wrap is useful in Byte and Word modes (see section 10.1), where it allows you to quickly set the number of bytes or words that are displayed to a line. It is also useful when coupled with soft wrap, since this gives the benefits of soft wrap (only breaking at word boundaries), while retaining the dynamically adjustable width.

6.3.2 Soft wrap

This controls how words are wrapped at line ends; when turned on, the display of paragraphs is reformatted dynamically as you type, in order to avoid words being split across lines. This works to the current display width - see section 7.1.1.

Note that no physical line ends are ever inserted - soft wrap merely affects how Zap displays your file.

6.3.3 Word wrap

This acts in a very similar way to soft wrap, except that line breaks are inserted at line ends as you type; the rest of the paragraph is reformatted accordingly. It can be seen as a 'hard' equivalent of soft wrap, because the wrapping it performs affects the file, and so will be preserved even if you turn off word wrap. Some modes may modify the behaviour of this slightly - for instance Email mode preserves quoting while the reformatting occurs.

The width that Zap word wraps too is controllable from the Edit->Type of wrap->Word wrap submenu.

A companion command to this, which reformats a single paragraph in the same way, is FORMATTEXT, which is on cF6, and also on the Misc->Alter submenu.

6.3.4 Line wrap

This is very similar to word wrap, except that the effect is 'local' - the rest of the paragraph is not reformatted as you type. Line wrap is mutually exclusive with both word wrap and soft wrap.

6.3.5 Infinite wrap

Infinite wrap extends the window wrap option so that the width of the window can be increased indefinitely (usually it is constrained by whatever you set the width of the window to - see section 7.1.1).

6.3.6 Auto soft wrap

Auto soft wrap will turn on soft wrap automatically if it thinks you need it (it checks to see if you have any long lines in the file). However it only does this when you first load the file, or when you change mode, so it is generally most useful as a saved option for a mode - see section 12.2.1 on how to use this.

6.3.7 Strong soft wrap

Strong soft wrap modifies the soft wrap option to strengthen the illusion that the different physical lines (as displayed by Zap) are separate entities. With it turned off, the start and end of lines are taken to be the start and end of logical lines, as usual (logical lines being lines which end in a line break); with it turned on, key presses such as cLeft and cRight (move cursor to start/end of line) will move the cursor within the physical line only.

This option will also affect how auto indent works (auto indent usually looks at the previous logical line; with this option on, it looks at the previous physical line, which in general will be less useful).

6.4 Keymaps

So far, you have been using the Default keymap - all the keystrokes have been the standard ones, chosen to be most useful for normal editing. However Zap has a range of keymaps available, which serve two purposes.

Firstly, they allow compound keystrokes - for instance, scF11 cX cS provides a different way of saving the current file. This is achieved by altering the current keymap - typically you have a keystroke which changes the keymap using the KEYMAPN command, which only remains in effect for the next keymap; thereafter you are dropped back to the basemap (unless the second keypress also uses KEYMAPN). This is exactly what's happening in the example above: scF11 executes KEYMAPN "Emacs", cX executes KEYMAP 2, and cS executes SAVEFILE. Thereafter the current keymap returns to the basemap (normally the Default keymap). KEYMAPN is case-insensitive - so KEYMAPN "EMACS" and KEYMAPN "Emacs" are the same.

See section 12.3.3 for more information about keymaps, and about how to configure new keymaps.

Clearly, being able to chain keystrokes together is a useful thing, since it allows you to access many more functions quickly via the keyboard than would otherwise be possible. However keymaps get used in another way. We've already used the phrase basemap, but we haven't really explained what it means. At any one time, each window has a current keymap, and also a basemap, which is simply the keymap that the current keymap drops back to after each keystroke. Clearly there are going to be times, when you are doing a particular type of editing, where you might want to stay in the new keymap for a while, instead of being dropped back to whatever your basemap is; you can do this by altering the basemap, by the BASEMAPN command (which works in the same way as the KEYMAPN command, except that the effect is more permanent), or from the Misc->Keymap submenu.

To change the basemap back to the default, use the DEFAULTMAP command, or use the Misc->Keymap->Default menu option.

6.5 Cursor behaviour

Zap has a number of options affecting how cursor movement and selection works.

6.5.1 Line select

This controls how selections are made and insertions positioned. With it turned on, selections which span more than one line are confined so that they always select entire lines; insertions which contain more than one line are always made at the start of the line where the cursor is, and not at the exact cursor position. This is much like the selection model implemented in BASIC mode - see section 10.4.

Though this description may sound obscure, and the option is usually turned off by default, it is often very useful. In modes like Assembler mode, where lines are rarely very long, it cuts out a number of operations - selections can be made lazily, and there's no need to manually align the cursor before each paste, and consequently you can work significantly faster.

6.5.2 Smart movement

This affects sLeft and sRight (move forward and backward one word), and related functions (such as the delete word command). It is turned on by default; when turned off these operations stop at spaces and not much else. With it turned on, the action feels more intelligent, with the cursor stopping more frequently.

6.5.3 Confine horizontally

With this option turned on, the cursor cannot be moved rightwards beyond the end of a line - instead it moves to the start of the next line. This keeps the cursor near existing editable text, and more accurately reverses the behaviour of cursor left.

6.5.4 Confine vertically

With this option on, when the cursor moves vertically into a line which does not extend horizontally as far as the current cursor position, the cursor is moved to the end of the line. However the preferred horizontal position is remembered, so if you then move vertically into a line which does extend far enough horizontally, the cursor will move back to where you want.

6.5.5 Free click

If on, cursor clicks with the mouse are not confined to the end of the line on which they are made. Instead, the cursor can be positioned anywhere in the visible region. This option may be of use to those generating ASCII art, or editing textual spreadsheets or similar (typically with Overwrite mode turned on).

6.6 Block editing: quickly editing all lines in a selection

Block editing allows you to quickly perform the same editing actions on all the lines of a selection. With it turned on, editing anywhere within the selection will perform the edit on all lines of the selection simultaneously. Block editing can be turned on from the Edit submenu.

There are two related features of Zap that you might like to investigate if you find that block editing isn't powerful enough for you. Learned sequences allow you to 'record' a set of actions and play them back - see section 9.5; the universal argument allows you to perform a single command an arbitrary number of times (see section 9.6).

6.7 Line editing

If line editing is turned on, then line breaks cannot be deleted by the user using Delete. Also, inserting a new line by pressing Return does so at the end of the line, rather than at the current cursor position. Instead, you can use the JOINLINE (join the current line to the following) and SPLITLINE (split the line at the current cursor position) commands, on cF1 and sF1 respectively.

This option is used in BASIC mode to emulate the old ARM Basic Editor.

6.8 Other options

Here are the remaining editing options. Some of these have already been introduced earlier.

On the Edit->Misc menu:

On the Edit menu:

On the Display->Misc menu:

6.9 Save options

For normal text-like modes (including most of the programming modes, such as C, Assembler, etc.), Zap has three options which affect how it saves files.

Firstly, there is support for DOS-style and Spool files - DOS files have line terminators CRLF (rather than just LF) and Spool files use LFCR. As mentioned earlier, if Zap detects that a file is a DOS file or a Spool file when it load sit, it will convert all the line endings and set the appropriate option, so that on saving the line endings are restored.

If you have a file where you want to keep the line endings as LF, but where Zap has recognised it as a DOS file or Spool file, you can turn the options off from the File->Save options submenu. DOS file is indicated in the titlebar as a B in the options, and Spool file as an S.

The third save option is 'strip spaces' (also on the File->Save options submenu). This simply strips all trailing spaces on lines before saving, and is particularly useful in programming modes.

The next section in the manual is chapter 7, which shows how to alter the way Zap displays things - the colours it uses, the font it displays the text in, and so on. It also looks at printing.

Alternatively, you could move on to chapter 8, which looks at Zap's powerful search and replace system.

Previous | Contents | Index | Next

© Copyright Zap Developers 1992-2004. All Rights Reserved.