if condition {cmds1}[ else {cmds2}];

This executes the commands given for cmds1 if condition is true, and executes cmds2 if condition is false (although specifying the else clause is optional).

Currently, condition may only be one of the following:

<searching>

This is true if an incremental search is currently in progress, and false otherwise. (See the ISearch.)

<noselection>

This is true if there is no primary selection.

<nosselection>

This is true if there is no secondary selection.

<insertmode>

This is true if you are not in insert mode.

<select num=line>

This is true if the selection number num aligns on line boundaries.

<select num=rect>

This is true if the selection number num is rectangular.

<select num=text>

This is true if neither of the above two are true.

The keyword else is included optionally, followed by a second command list. If else is included and condition is not true, then the second command list executes.

The final closing brace is followed by a semicolon.

Example

if <noselection> {SelectLine}; Cut1

If there is no selection, then this selects the entire line. The Cut1 command is always executed.

if <noselection> {ContinueSelection; SOL} else {Delete}

If there is no selection, then this selects from the current cursor position to the end of the line. If there is a selection, it is deleted.

Related topic:


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.