Michael Cairns: More on the ISPF Editor and SDSF
Learn the basic line commands: D for Delete, C for Copy, I for Insert, M for Move and the block commands and use a pair of characters mentioned. So, for example DD on line 10, and DD again on line 20 will (D)elete all lines from 10 through 20 inclusive. Using the block command with the (A)fter and (B)efore line commands-for example MM on line 10 and MM again on line 20, then place an A on line 30-will move lines 10 through 20 from their current location to the line (A)fter line 30. Similarly, a B would place them (B)efore line 30.
As with block commands, you can use a single line-command character followed by a number (i.e., I5 will insert five blank lines before the current line, while D10 will delete the current line and the following nine lines).
More advanced editing requires knowledge of the left- and right-shift operands: the COLS, BNDS, X and FIND/CHANGE commands. A right bracket-)-shifts the text on the current line one character to the right, while the left bracket-(-shifts text to the left. Following the line command with a number (i.e., )5) shifts the text five places to the right. Combine these with their block-command equivalents, and you can indent or pull back large blocks of programming code very effectively.
This is when the e(X)clude line command becomes useful because it removes the current line from the display window. As a block command, it removes all lines between the first XX and the next. You can exclude 10 lines with the line command X10.
Excluded text can be either selected or unselected for processing a FIND or CHANGE primary command. This is useful when you want to change all occurrences of a string except in a few places-and is especially useful when the data set is large or the string occurs in many places.
The primary commands FIND and CHANGE accept similar arguments. “FIND a” highlights the first “a” character occurring in the currently edited data set. Press PF5 to find the next occurrence. “CHANGE a b” does as the syntax suggests, and changes the first occurrence of “a” to a “b.” Instead of pressing the Enter key after a CHANGE command, try PF; this highlights the first string to be changed rather than actually updating the text. Press PF6 to process the change command, then PF5 again to highlight the next occurrence. Continuing to press PF5 skips changing the highlighted text and simply finds the next occurrence.
An extension to the base syntax of both FIND and CHANGE introduces the parameters X for e(X)cluded and NX for (N)on-e(X)cluded lines. So, if you’ve used the XX block command to exclude a large part of your program code, you can then globally change one string into another either in the excluded lines or only in the visible lines (i.e., “FIND fred NX” finds the string “fred,” but only in the Non-eXcluded lines on the screen, while “CHANGE fred joe ALL X” changes all occurrences of the string “fred” to “joe,” but only in the lines you currently have eXcluded).
Another command using similar constructs is the e(X)clude primary command, which has a syntax virtually the same as the FIND command. To exclude all lines containing the string “robot,” issue the following primary command: “X robot ALL.” To then delete all of the other lines in the data set issue: “DEL ALL NX” (the opposite action is “DEL ALL X”).
In the examples, I’ve generally quoted the target strings or the FIND/CHANGE commands, which is most often unnecessary unless the target contains embedded spaces or quotes. It may also be useful to know how to undo and exclude; the line commands (F)irst or (L)ast reveals lines in the excluded text, (RES)et removes the exclude altogether.