The basic unit of data so far as the ISPF editor is concerned is the record or line. There are a number of commands available within the editor to allow you to copy or move entire lines (or blocks of lines) not only to a different location within the same file but also to a location in a completely different file. Most of these options require a combination of both primary and line commands in order to perform the copy or move.
Let's start with the simplest of these tasks, copying or moving lines to a different location within the same file. This is the one instance of copying or moving lines that is done entirely using line commands. You identify the line(s) to be copied or moved using the c or m to mark the line to be copied or moved respectively. You can also specify a number next to the command to indicate that the specified number of lines starting with this one are to be copied or moved. Another way to indicate that multiple lines are to be copied or moved is to use cc or mm markers on both the first and last lines of the block to be copied or moved.
You then mark the location within the file to which the lines are to be copied or moved by placing an a command on the line above where you want the lines to be placed or a b command on the line below where the lines are to be placed. You can also overlay the lines over existing lines using the o or oo command. Once you have entered this command the line(s) will be copied or moved to their new location.
Let's now consider how we can copy or move lines from within one file and create a new file to contain those lines. To do this we need to be editing the file from which the lines are to be moved or copied. We mark the lines to be copied or moved using line commands exactly as if we were going to move them to a different location in the same file but instead of marking a location where the lines are to be moved we instead go to the primary command line and enter a create command specifying the name of the file that we want to create. Once you have entered this primary command the new file will be created and the marked lines will be moved or copied into it.
We can also copy or move lines to replace the entire contents of an existing file instead of creating a new file. To do this we use the replace primary command instead of create.
We can also perform the reverse of this, copying or moving the entire content of another file to insert into the file that we are currently editing. To do this, we first specify the copy or move primary command followed by the name of the file that is to be copied or moved. We then enter a line command to mark where the file is to be inserted using the a, b, o, or oo command exactly the same as if we were copying or moving from elsewhere in the same file. Once you have entered this command the line(s) will be copied or moved to their new location and in the case of a move the source file will be deleted.
Finally, let's consider the situation where we want to move lines between files but where we don't want to include the entire content of either the source or destination file. You could do this using the create and move commands that I have already discussed but this involves creating a temporary file in between the two steps and entering the name of that temporary file twice. That used to be the only way to copy part of one file into another but more recent versions of the editor have offered two more commands that avoid your needing to create a temporary file. These commands are the primary commands cut and paste. When you want to copy of move lines from within one file into another you first edit the file from which the lines are to be copied or moved and mark them in the usual way. You then enter the cut primary command (without any parameters). Once you have entered this command the lines are copied or moved to a temporary work area. You now switch to the file into which the lines are to be placed and enter the paste primary command (again without parameters) and mark the location in the usual way where the lines are to be placed.
This article written by Stephen Chapman, Felgall Pty Ltd.