| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |
Robelle Sponsor Message

May 2001

Get the most out of your Robelle tools

Qedit: boxes of text

By Bob Green

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 in classic 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@robelle.com
 


Copyright The 3000 NewsWire. All rights reserved.