Here are some examples of what can be done with KEDIT's ALL command and with some related commands. If you aren't already familiar with the ALL command, an introduction to the ALL command is also available. Even if you are already familiar with KEDIT's ALL command, you might not be familiar with the variety of uses to which it can be put. The information in this article applies to both KEDIT for Windows and to KEDIT 5.0 for DOS and OS/2. The examples involving regular expressions are an exception; regular expressions are only supported in KEDIT for Windows.
To find all lines within a file that contain a given string, use the ALL command and specify the string involved within a pair of slashes. For example, to find all occurrences of the string "abc", you would use:
ALL /abc/Your screen would then look something like this:
When you are finished working with the selected subset of the file, issue the ALL command with no operands to return to viewing the entire file:
ALLThe general format of the ALL command is:
ALL targetwhere target is usually the text string that interests you, enclosed within a pair of slashes, but can actually be any kind of KEDIT target, such as a regular expression target or a BLANK target (which matches blank lines). The examples in this article use several kinds of KEDIT targets, so in addition to learning about the uses of the ALL command, you'll also see a variety of ways to specify targets within KEDIT.
ALL /joy/It would find lines that contain the word "joy", but it would also find lines that contain the words "enjoy" or "joyfully". If you are interested in the word "joy", but aren't interested in words, like "enjoy" or "joyfully", which happen to contain the string "joy", you can use WORD in your target specification to indicate this:
ALL WORD /joy/To find all lines that don't contain the word "joy", you could use
ALL ~WORD /joy/
In the examples given so far, KEDIT looks for any occurrence of the target string, regardless of where in a line it appears. But what if you are only interested in lines that begin with a given string?
The easiest way to handle this is to use a regular expression, which is a type of target that gives you more detailed control over how KEDIT searches operate. To indicate that you are using a regular expression target, use REG or REGEXP before the target string. For example:
ALL REG /^abc/The results might look like this:
Here, REG indicates that a regular expression target is being used. Within a regular expression, some characters take on a special meaning. A caret ("^") at the start of a string indicates that KEDIT is to look only at the beginning of a line, rather than anywhere in a line, for the text that follows. So in this example, KEDIT looks for lines that have "abc" at the beginning of the line, in columns 1 through 3.
A variation of this would be to look for lines that don't necessarily have "abc" in column 1, but that do have "abc" as the first nonblank characters:
ALL REG /^ *abc/This command tells KEDIT to start looking in column 1 of a line, and to look for zero or more blanks (an asterisk in a regular expression means that KEDIT is to look for zero or more of whatever immediately precedes it, and in this example the asterisk is preceded by a blank), followed by "abc".
The results might look like this:
Just as a caret at the start of a regular expression target means that KEDIT is to look for lines that begin with the specified text, a dollar sign ("$") at the end of a regular expression means that KEDIT is to look for lines that end with the specified text. So in this example, KEDIT looks for all lines of the file that end with "abc".
ALL REG /abc$/For a full discussion of KEDIT's regular expression support, see Section 6.6 of the "Targets" chapter in the KEDIT for Windows User's Guide.
MORE targetcauses KEDIT to add any lines in your file that aren't already selected, but that do match the specified target, to the set of lines selected for display.
LESS targetcauses KEDIT to remove any already-selected lines that match the specified target from the set of lines selected for display.
For example, assume that you have a file with data about U.S. presidents in which you want to find all references to President John Kennedy, and you issue the command
ALL /Kennedy/If you then decide that you also want to see any references to President Lyndon Johnson, you might then issue the command
MORE /Johnson/You will then be viewing all lines from your file that contain "Kennedy" or "Johnson". If you then notice that, in addition to the references to Presidents John Kennedy and Lyndon Johnson, you have also selected a number of references to President Andrew Johnson, you could use the command
LESS /Andrew/to stop displaying them.
ALL /abc/ DELETE * ALLIn this set of commands, the first command tells KEDIT to display only the lines in your file that contain "abc".
The DELETE * command normally tells KEDIT to delete everything from your current position in the file through the end of the file. In this case, however, since the ALL command has been used to select the lines that contain "abc", only those lines are deleted.
The final command, ALL, tells KEDIT to once again begin displaying everything in the file, which by now consists only of the lines not containing "abc".
ALL BLANKwill display all blank lines in your file, and
ALL ~BLANKwill display all nonblank lines in your file.
And the commands
ALL BLANK DELETE * ALLwill delete all blank lines in your file.
After you have used the ALL command to select a subset of your file for display, it is sometimes useful to temporarily view the entire file, so that you can view the selected lines in the context of the entire file, and then to return to working with the subset of the file.
One way to do this is by using Alt+Plus (that is, by pressing Alt in connection with the "+" key on the numeric pad.) You can press Alt+Plus repeatedly to toggle between viewing your entire file, and the portion of your file selected by the last ALL command.
Another way to do this, if the bottom toolbar has been enabled in KEDIT for Windows via SET TOOLBAR ON BOTH, is to use Show All Lines toolbar button to display all lines of the file, and to use the Hide Excluded Lines toolbar button to display only the lines selected by the ALL command.
When you issue an ALL command, KEDIT normally displays "shadow lines" that give information about portions of your file that have been excluded from display.
The shadow lines give useful information, but can also take up a fair amount of room on your display. You can turn shadow lines off with:
SET SHADOW OFF
and you can turn them back on with:
SET SHADOW ON
After you issue an ALL command to select a subset of your file, it is sometimes useful to know how many lines have been selected. You can use QUERY NBSCOPE to find this out. QUERY NBSCOPE returns two pieces of information. The first, and the one that you are usually interested in, is the number of lines currently selected. The second gives you the location of the current line within the set of selected lines.
For example, assume that you have issued the command
ALL /abc/If you then issue the command
QUERY NBSCOPEand KEDIT displays the result
NBSCOPE 155 57The first number would indicate that there are 155 lines in the current file that contain "abc". The second number would indicate that you are currently positioned at the 57th of these 155 lines.
Users of the ALL command should also be aware of the TAG command. While the ALL command displays only the lines of your file that match the target that you specify, the TAG command leaves the entire file displayed but highlights the lines that match the target. For example:
TAG /abc/This command will highlight all lines of your file that contain the string "abc":
Just as you can issue the ALL command with no operands to finish working with the selected subset of your file, you can issue the TAG command with no operands:
TAGto turn off TAG command's highlighting.
Sometimes it is useful to see which lines of a file have been altered since you began editing the file. You can do this with the command
If, for example, you try to close a file and KEDIT asks if you want to save your changes, but you can't remember what those changes were, this command can come in handy. Note that ALL ALTERED will show you all lines that have been added to your file or that have been changed, but it doesn't show you which lines have been deleted from your file.
A related command is
SET HIGHLIGHT ALTEREDWhen HIGHLIGHT ALTERED is in effect, KEDIT highlights all altered lines, highlighting additional lines as you make additional changes to your file, so it is always clear which lines of your file have been altered and which lines haven't.