Qedit

Qedit for Windows: Boxes of Text

Tips on Rectangular Editing

An editing situation that I have always found cumbersome is arranging columns of data. For example, suppose you have an HTML table that you want to double up:

						
        <tr><td>Apples<td>10 cents
        <tr><td>Oranges<td>12 cents
        <tr><td>Tangerines<td>30 cents
        <tr><td>Watermelon<td>50 cents

is to become the following:

        <tr><td>Apples<td>10 cents<td>Tangerines<td>30 cents
        <tr><td>Oranges<td>12 cents<td>Watermelon<td>50 cents

Of course you can copy the text by hand for each line and then delete the leftover <tr> tag lines, but that is a lot of manual work. What I would like to do is just point to the column of text that needs to move, by making a rectangular selection on the screen, then use the clipboard to cut and paste it.

Qedit for Windows lets you do this:

Control-Drag — To select one column in your file, hold down the CONTROL (CTRL) key while you drag the mouse. This highlights a rectangular selection on your screen.

To copy one column to the clipboard, select a rectangle and use either Copy (CTRL+C) or Cut (CTRL+X) to put it in the clipboard. In this case I select everything after the <tr> in the lines that I want to move up. For example, Figure 1 shows a rectangular selection within some table Tags.

To append the clipboard column after the existing column, I create another rectangular selection in the empty space to the right of the column and Paste (CTRL+V) into it. I have now doubled up the columns.

A few tips for rectangular editing

Use the relative line numbers shown in the lower right corner of the document window (far right on the document status bar) to calculate how many lines there are in total and thus how many lines per column. Insert a blank line at the “division” point so that you can spot it while pasting. Since it won’t come out even most of the time, copy a few extra lines and then edit the last couple of lines of the combined table.

Figure out the longest line in the first column and start your rectangular selection at that column on the top line of the table. But you also have to make your selection wide enough, so estimate the longest line in the clipboard and add that to the starting column number of the selection to create the right edge. The column numbers appear in the lower right corner of your document window, just like the line numbers. I start the selection at the top right corner, drag left to the top left corner, then drag down to the bottom left corner. In this way I can see the text to the left as I am dragging and I know when to stop! Another way to know when to stop is to watch the size of the selection in the lower right corner.

Don’t make your paste rectangle too short (less lines than were copied to the clipboard), or you may lose some lose lines at the end of your clipboard. If the paste rectangle is too long (more lines than were copied to the clipboard) then lines from the top of the copy rectangle are repeated in the paste area. If the copy rectangle is wider than the paste rectangle, lines from the clipboard are truncated. If the paste rectangle is wider then lines are padded with blanks.

The text in the paste rectangle, if any, is replaced during the paste operation. If you wish to blank out the rectangle first, you use the Delete function of the Column command on the Edit menu. Make sure you enable the Fill with spaces option on the Delete Columns dialog box. If you wish to insert the copy rectangle, use the Insert function of the Column command on the Edit menu to insert an appropriate number of blanks. Then select the empty area as the paste rectangle.

By the way, if you have Tab characters in the lines, Qedit takes care of ensuring that the text remains aligned visually, by converting Tabs into Spaces and vice-versa, as needed.

How would you do this with commands in host-based Qedit?

The basic technique with commands is simple: Set Left at the left edge of the source rectangle and Hold the lines, then Set Left at the left of the Paste rectangle, and finally do a Replace $Hold to copy replacement text for those columns only from the clipboard. This effectively does a merge.

List “<tr>” !count table lines=100
Find First; Find “<tr>” !find first table line
List *+50 !find start of 2nd col
Zz */ *+49 !mark 2nd column
Set left 5 !set margin after <tr>
Holdq zz !”hold” col 5-end
Set Left 1 !reset margin
Delq zz !delete the 2nd col
Find First; Find “<tr>” !go back to 1st col
Set Left 50 !set 2nd col margin
Replace $Hold,*/*+49 !insert the column
Set Left 1 !reset the margin

The column move is do-able with edit commands, but it is certainly more work than a couple of mouse drags and clicks!

Bob Green


Fill Columns With Text

By François Desrochers

Host-based Qedit offers the ability to work on columns. One common example is to put the same text in specific columns of a range of lines. For example, to put New text in columns 1 through 10 on all lines, you would do:

     /Change 1/10 "New text" All
Even though the Qedit for Windows Replace command can work on columns, you can't use it as it only replaces existing string occurrences found within these columns.

Here's how you change columns with Qedit for Windows:

  1. Select the fill text. If it's not already in the file, you should type it in temporarily.
  2. Copy the text to the clipboard (CTRL+C, Edit | Copy).
  3. If it was a temporary text, you can delete it now.
  4. Use a rectangular selection (Shift+left mouse button) to select the columns and all the lines where you want to put the text in.
  5. Paste the clipboard (CTRL+V, Edit | Paste).
That's all there is to it. The explanation is simple. When Qedit for Windows pastes the clipboard into a rectangular selection, it can do a number of things depending on the number of lines in the source (clipboard) and the destination (rectangle).
  1. If the clipboard is wider than the rectangle, pasted lines are truncated.
  2. If the clipboard is narrower than the rectangle, pasted lines are padded with spaces.
  3. If the clipboard has fewer lines than the rectangle, the clipboard content is reused until the rectangle is filled.
  4. If the clipboard has more lines than the rectangle, the extra lines are dropped.
To change columns, you are taking advantage of behavior #3. If the source text is a single line, that line is going to be repeated everywhere. If the source text contains 3 lines, these same 3 lines are going to be repeated as in:
     This is Line1.
     This is Line2.
     This is Line3.
     This is Line1.
     This is Line2.
     This is Line3.
     This is Line1.
     This is Line2.
To define a rectangular selection, you have to hold the Shift key down while dragging the mouse with the left button down. This works fine if you have a small number of lines to select. It's not as practical if you have a large number of lines. Here are 3 ways to make that easier.

Partial selection: Start and extend the selection

  1. Start the rectangular selection (CTRL+drag)
  2. Move to the end of the rectangle using the scroll bar
  3. Hold CTRL and SHIFT and click

Partial to the end: Start and extend to the end of the file

  1. Start the rectangular selection (CTRL+drag)
  2. Hold CTRL, SHIFT and END

Select all lines: Use the Select Columns QSL script

  1. Start the rectangular selection (CTRL+drag)
  2. Scripts | Robelle | Sortlines | Select Columns

François Desrochers


New: Syntax Coloring in Qedit for Windows

Use "Favorites" to Organize Projects

Advanced Selection Tips in Qedit for Windows

More Tips On Qedit for Windows