WinPTE.com

 

Power Block Editing Mode

Power Block mode is a special editing mode where the same editing action (typically text inserted or deleted) is performed on multiple lines of text, interactively and at the same time. You edit a single line in a selection and the same operation is applied to all or some of other lines in the selection. see animated sample

Of course this only makes sense when the same editing actions need to be applied to multiple lines. If you think this is a rare case then you are thinking 'Word processor' type text editing and not 'Source Code' type of text editing. Programs have more regular structure that creates plenty of opportunities for Power Block Mode style of editing.

I have been using Power Block Mode for over 5 years, I have learned to see source code editing in terms of common operations, it is now second nature and does not get in the way of the task at hand. On the contrary, because the same operations are applied to multiple lines, typos are reduced, and if they do occur they occur consistently which means that Power Block Mode can be used to correct all of them at the same time. I can assure you that this editing feature is the most powerful and most addictive part of WinPTE.

Before getting into the details, I would like to point out that due to its intuitive behavior and visual nature Power Block Mode is much easier to use than it is to understand from reading the text. So don't be tempted to skip this because it seems too complex to be useful. It is one of WinPTE greatest productivity boosters.

Conceptual Discussion of Editing

Lets start by examining the edit cursor concept which is found in all editing programs and works well for editing a single line of text. Conceptually it is nothing more than visual representation of the position in the file where the next edit operation will be applied. Some operations do not modify text and instead are used to modify the position of the cursor itself.

The single line cursor idea is extended in Power Block Mode to multi line editing and this extended cursor is called the Power Cursor. The power cursor visually communicates the position where the next edit operation will be applied, except it does so for every line in the selection with each line having its own position that is independent of the positions on other lines. Additionally, some lines may not have a cursor position at all, which means that the next operation will not be performed on those lines.

Modifying the individual line positions in Power Block Mode requires some new concepts to allow quick and consistent modification of cursor positions on all lines. Having to manually select a position on each line would not be very useful. Power Cursor positions are controlled by the single "edit cursor" that is normally used to edit a single line because we are all used to doing it, and therefore can do it efficiently.

Additional basic editing functions are used to extend the delete and backspace operations to allow these to be used for modifying more than just a single character. That way the effect of the operation operation will be dictated by the content on each individual line in the selection. To this end WinPTE defines modifiers for backspace and delete keys that 'escalate' the extent of modifications made by these keys, with backspace having effect on characters to the left of cursor and delete to the right of cursor.

Modifier
Operation
None
Standard, affects one character.
Ctrl
Delete all immediate consecutive spaces.
Ctrl+Shift

Operation determined by the first character on which the operation is performed:

  • blank : delete consecutive blanks
  • identifier character: delete to start/end of alternating caps delimited word
  • all others: delete consecutive non-identifier characters
Alt

Operation determined by the first character on which the operation is performed:

  • blank : delete consecutive blanks
  • identifier character: delete to start/end of identifier
  • all others: delete consecutive non-identifier and non-blank characters
Shift+Alt
Delete leading blanks (if any), next word (delimited by blanks), and trailing blanks. Fast way to clear leading/trailing keywords or identifiers on a line.

 

Modes: Absolute, Start Relative, End Relative and Snapshot

Absolute mode is the simplest to understand, the power cursor will be in the same position for every line in the selection. It is simply a vertical extension of the edit cursor. Moving the edit cursor moves all the individual power cursors to follow suit.

Absoulute:

Relative mode places the individual cursor position for the line at an offset from either the first or last non-blank character for that line. The offset is equal to the relative position of the edit cursor from the first or last non-blank character of its line. For first non-blank relative mode, called Start Relative to make it shorter, the Power cursor's shape will follow the indentation level of the selected lines. For last non-blank relative mode, called End Relative, the cursor shape will follow the visible end of line of the selected lines.

Start Relative:

End Relative:

In Snapshot mode the individual cursor positions are independent of each other, taking a snapshot of the power cursor freezes the shape of the Power Cursors and moving the edit cursor will simply translate the whole Power Cursor without changing its shape. Effectively moving right moves all cursors right, left moves them all left, up or down moves all up or down.

Snapshot Mode:

Position Filters and Line Filters

Additionally filters may be applied to the individual power cursors that can change the position of each cursor or simply disable the cursor for that line, as in the case of Line Filters. These filters are used to refine the position of the power cursor on each line or remove the power cursor from that line. Line filters are not applicable to the Snapshot Mode and are only used in the Relative and Absolute modes. Position Filters can be used in any mode.

Line Filters

If the filter terminology seems to be reversed then you should think of these as color filters. A Red filter actually passes red through and filters the rest. Similarly Blank Lines Filter lets blank lines pass through unmolested, and filters out the rest.

Position Filters

The Search Filters deal with two cursor positions, one where the search begins and the other being the location where the search criteria is met. Both of these are displayed visually to the user. The start of search position is shown as a hairline cursor with the final cursor position shown normally.

Only one filter can be active at any one time, however a Snapshot of the current power cursor positions can be taken and subsequent filter operations will apply to the snapshot, having the effect of multiple filtering.

The setting of the search filter criteria is done in a script, the script modifies the search criteria depending on the character at the edit cursor position for search forward or the character left of the edit cursor if searching backward.

Character
Search Condition
Space Search for the first non-blank character.
Valid identifier character Search for the character sequence from cursor to the end (forward search) or beginning (backward search).
any other character Search for the character.

Using Power Block Mode

Now that we have some concepts out of the way lets see how these translate into real life application. The easiest way to start using Power Block Mode is via the toolbar.

  1. Toggle Power Block Mode
  2. Snapshot Mode, takes a snapshot of the current power cursor shape and select snapshot mode
  3. Start Relative Mode, clears existing snapshot and enters Start Relative Mode
  4. Absolute Mode, clears existing snapshot and enters Absolute Mode
  5. End Relative Mode, clears existing snapshot and enters End Relative Mode
  6. All Lines Filter, selects All Lines filter
  7. Non-Blank Lines Filter, selects the Non-Blank Lines filter.
  8. Blank Lines Filter, selects the Blank Lines Filter.
  9. Invert Power Cursor Positions, for every line in the selection removes the cursor if it exists, and if it does not then it places it at the edit cursor position.
  10. Search Forward Position Filter
  11. Search Backward Position Filter

Here is an animation of using Power Block editing to convert C/C++ pre-processor definitions to skeleton switch labels. Notice that we start off with the Absolute Mode where the Power Cursor is a vertical extension of the edit cursor. All editing is performed on a single line, the rest are edited by WinPTE. It takes the same amount of effort to edit 2 lines as it does 100:

 

Site Map | Privacy Policy | Contact Us | ©2004 Winpte.com