DELETE—Delete Lines
The DELETE primary command deletes lines from the data you are editing.
Note: As a precaution against error,
there is no DELETE ALL command. To delete all lines, see Description.
Syntax
- ALL
- Specifies that all selected lines are deleted. The DELETE command, unlike FIND, CHANGE, and EXCLUDE, does not accept NEXT, FIRST, PREV, or LAST. ALL is required to emphasize that NEXT is not the default.
- X
- Restricts the lines deleted to those that are excluded.
- NX
- Restricts the lines deleted to those that are not excluded.
- labela, labelb
- Labels identifying the start and end of the group of lines which
are deleted, including the lines with the labels. To delete one line,
enter the same label twice.
For more information about using labels to identify a group of lines, see Labels and line ranges.
Description
To delete all lines,
do one of these:
- To delete all lines by using the editor-defined labels:
DELETE ALL .ZFIRST .ZLAST
- To delete all lines by first resetting any excluded lines to make
them not excluded, and then deleting all lines that are not excluded:
RESET; DELETE ALL NX
Examples
In the examples that follow, .labela and .labelb represent the two labels that show the range of lines to be deleted.
- To delete all excluded lines:
DELETE ALL X
- To delete all not excluded lines:
DELETE ALL NX
- To delete all excluded lines within a range:
DELETE .labela .labelb X
- To delete all not excluded lines within a range:
DELETE .labela .labelb NX
- To delete all lines within a range:
DELETE .labela .labelb
You can more easily determine which lines to delete in a large data set by excluding lines that meet some criterion, or by leaving all lines that meet the criterion non-excluded. Then, with DELETE you can delete many lines. For example, to delete all blank lines in a data set, type these commands on the command line and press Enter after each one:
- First, reset all excluded lines:
RESET X
- Then, exclude lines containing characters that are not blanks:
EXCLUDE ALL P'¬'
- Finally, delete the non-excluded lines, which contain only blanks:
DEL ALL NX
Another way to do the same thing is this:
- First, exclude all lines:
EXCLUDE ALL
- Then, find all lines containing a character that is not a blank:
FIND ALL P'¬'
- Finally, delete the remaining excluded lines, which contain only
blanks:
DEL ALL X