Shifting Data

Shifting Data

Contents of Article


Differences between Column Shift and Data Shift line commands

Indent Shift - a new kind of Column Shift line command

Data-Shifting Insert-Mode function

Data-Delete function

Data-Backspace and Data-Delete-Mark


When you edit data, the editor automatically shifts characters on a line to the left or right to accommodate insertions or deletions. This shifting can be either implicit or explicit. Implicit shifts occur when INS mode is in effect when you press the Insert key, deleting characters with the DEL key, or when the CHANGE command string-2 length is different from the string-1 length.

There are three new facilities available for shifting of data.  These are Data-Shifting Insert Mode, and the Data Delete function, described at the end of this section, and the Indent Shift line commands described here.

Explicit shifts occur when you use the following line commands:

Two columns is the standard default for shift operations. This default can be changed to any number of columns desired (in the range of 1 through 999 columns) by a General Options setting.

When shifting a block of lines more or less than the default, enter the amount on the first or last line of the block. If you enter it in both places, the line shifts only if both amounts are the same.

Differences between Column Shift and Data Shift line commands

There are some significant differences between Column shifts and Data Shifts.  Shifting occurs within the column boundaries (either the default - the whole line) or those specified with the BOUNDS command or the BNDS line command.  

Column Shift moves all characters within the bounds without altering their relative spacing.  Characters shifted past the bounds are deleted.  That is, blanks are inserted at the bound from which the characters are being shifted, and the characters are deleted at the opposite bound.  So, this shift is called a destructive shift because information shifts within column boundaries without regard to its contents, and can result in the loss of data with no error being noted.  

Data Shift moves characters non-destructively within the BOUNDS.  The end-result of a data shift is a change in the widths of one or more spans of blanks; nonblank data will not be changed or deleted.

For data shift left attempts that exceed the current Left BOUNDS setting, text movement stops at the left bound.

Note: The ISPF editor marks lines with ==ERR> flags when a data shift operation can only be partially completed, either because of the data contents of the line or the current location of the BOUNDS.  SPFLite recognizes the same conditions, but currently does not support the display of ==ERR> flags.  Instead, it will display a message if there were any lines that could not completely shifted.  The message will say "Data shifting incomplete" and will report the number of lines for which the full shifting amount could not be applied.

Data shifting works by moving contiguous spans of nonblank characters as a unit, and 'pushing' adjacent spans of characters as needed to make sure there is no data loss.  When spans of nonblank characters are separated by only one space, that space is never collapsed (deleted); that way, the spans of nonblank data are never 'run together'.


For a data shift right, shifting can occur up to and including the right bound column.  If the right bound is MAX, right-shifting the data line may result in making it longer.

For a data shift left, shifting can occur up to but not including the right bound column.

If left BOUND column of the data line is nonblank, it defines a "label" field, which is locked at that position and is not moved during either a left or right data shift.

Note:  The Data Shift commands are intended to allow for non-destructive shifting of the kind of data that appears in typical programming-language statements, by applying some general rules.  These rules require a certain amount of parsing and analysis of your data.  The support in SPFLite for Data Shifting commands has been extensively tested, and great efforts were made to ensure that it handles data in an ISPF compatible manner.  However, because these general rules may or may not be applicable or useful in your particular situation, you should inspect the results of a Data Shift to ensure you obtained the results you intended, until you are familiar with how this feature operates.


=BNDS>    <                                               >

000010    Word1    Word2     Word3                    Wordn

If a Data Shift Right command of >10 is entered on line 00010 the result would be

=BNDS>    <                                               >

000010    Word1              Word2     Word3          Wordn

As can be seen,  Word1 and Wordn  have been left alone, and only the other data shifted.

Note: Data Shift line commands have the following features:

Indent Shift - a new kind of Column Shift line command

SPFLite supports the Indent Shift facility.  In terms of how data interacts with Bounds, as described above, an Indent Shift may be thought of as a specialized form of Column Shift.  When there is no n value on an Indent Shift line command, the number of columns shifted is the same as the default shift columns value that appears in the General Options dialog.  So, a simple ] command with no n value works the same way as ) does.  And, as always, a command like )n overrides the default, so if the default is 4 and you say )3 you indent 3 columns.

However, when a command like ]n is used, the n value is not an override.  Instead, the Indent Shift takes the established default number of columns and multiplies it by n.  

So, if the default columns was 4, and you issued a ]3 line command, the number of columns shifted would be 4 x 3 = 12.  Suppose you are entering data, and wanted it formatted so that there were indentations at 4-column boundaries.  Now, if you wanted to indent by 3 "indentation levels" you could use ]3 rather than )12.  

Using Indent Shifts, you no longer have to think in terms of columns, but in terms of the number of indentation levels you are working with.  

As an added convenience, because the Indent Shift line commands use the [ and ] bracket keys (which are non-shifted keys on many keyboards) these commands will be a little easier to type than ( and ) for most users.

Data-Shifting Insert-Mode function

There is a close relationship between SPFLite's standard Insert Mode and the ) Shift Right line command.  For example, if a line command of )4 is issued, four blanks are inserted at the beginning of the line, which is the same thing that would happen if Insert Mode is enabled, then the cursor is moved to the beginning of the line, and then finally the spacebar is pressed four times.

It is desirable to also have a relationship between an “insert mode” and the > Shift Right Data line command.  It is now possible with the Data Shifting Insert Mode, enabled by the (DataInsert) keyboard function.

A suggested mapping for this key is Ctrl-Insert or Shift-Ctrl-Insert.  

By the way, it's technically possible to map the Shift-Insert key also, but that is not recommended.  If you are entering capital letters by holding down the shift key and then press Insert, you probably just want to enter normal Insert Mode and not do something special.

The (DataInsert) function will put the editor into Data Shifting Insert Mode, somewhat similar to the INS mode that occurs when the Insert key is pressed.  Data Shifting Insert Mode allows data to be inserted into lines in a way similar to the way that the Data Shift line command > operates.  Because of this, if you are inserting data that is formatted into columns, (DataInsert) will not disturb the column alignment, as long as two or more blanks separate the columns.

Looking at the example below, suppose we want to insert some data before the commas on each line, and we do not want to disturb the column containing CCC but want to keep it aligned.  It may be possible to do this with BOUNDS, but BOUNDS can be inconvenient to use.  With Data Shifting Insert Mode, you can enter data and have SPFLite maintain the alignment of columns in a way similar to how a word processor would maintain the alignment of tabbed columns (without actually using tabs).  


When Data Shift Insert Mode is in effect:

For example, assuming the following data lines:

000001 A,B       CCC

000002 AA,BB     CCC

000003 AAA,BBB   CCC

Suppose we want to add 1, 22 and 333 before the commas on the data lines above.  Using regular Insert Mode, this would first produce:

000001 A1,B       CCC

000002 AA22,BB     CCC

000003 AAA333,BBB   CCC

and the lines would have to be ‘repaired' to restore the alignment of the CCC column.  With Data Shifting Insert Mode, the strings ending in B would be pushed to the right without moving the CCC column, as long as no data loss occurred.  On line 3, that is not possible, and so its CCC value has to be pushed over:

000001 A1,B      CCC

000002 AA22,BB   CCC

000003 AAA333,BBB CCC

When multiple spans of blanks exist, they get “compressed” in left-to-right order, starting from the point on the line where the cursor is positioned and going rightward as needed.

When a key mapped to (DataInsert) is pressed, the editor enters Data Shifting Insert Mode.  To distinguish this mode from regular Insert Mode on the Status Line, the regular INS indicator is displayed in reverse video as INS instead.

When the editor is in Data Shift Insert Mode, another function key mapped to either (Insert) or (DataInsert) will return the status line to the OVR indicator.

Data-Delete function

This function will delete text in the same way that (Delete) does, except that the data being "pulled left" by the delete action is "delimited" by any span of two or more blank characters.  Because of this, if you are deleting data that is formatted into columns, (DataDelete) will not disturb the column alignment, as long as two or more blanks separate the columns.

Unlike the (DataInsert) function, (DataDelete) does not define or toggle a "mode" but merely deletes a character, as described below.

A suggested mapping for this key is Ctrl-Delete or Shift-Ctrl-Delete.

Let's take the same data from above, inserting an additional line, and compare (Delete) and (DataDelete).  Assuming the following data lines:

000001 A,B       CCC

000002 AA,BB     CCC

000003 AAA,BBB   CCC


Suppose we want to delete the words A, AA, AAA and AAAA.  Using regular (Delete) function, this would produce:

000001 B       CCC

000002 BB     CCC

000003 BBB   CCC

000004 BBBB CCC

and the CCC column gets shifted over.  Using the (DataDelete) function produces:

000001 B         CCC

000002 BB        CCC

000003 BBB       CCC

000004 BBBB CCC

Note that the CCC column gets shifted over on line 4.  That is because there was only one space between the original BBBB and the CCC, and so the string "BBBB CCC" is treated as a "single unit" of text, and is pulled to the left.  On lines 1-3, the CCC string in each case was preceded by two or more spaces, and so it does not get pulled to the left on those lines.

Data-Backspace and Data-Delete-Mark

Two new functions are available that involve data shifting.  These are (DataBackspace) and (DataDeleteMark).

(DataBackspace) is essentially a cursor-left-one followed by a (DataDelete).

(DataDeleteMark) will delete highlighted (marked) text in the same way that (DataDelete) does, but if there is no text highlighted, the function does nothing.

Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation