What happens if you select multiple columns and then drag one of the selected column boundaries?

One of UltraEdit's most powerful features is its easy-to-use column mode. Column mode, also referred to as block mode or block editing, allows you to select columns of data (as opposed to rows) by changing the way you can select text in the editor. With column mode, you can edit columns of data in just seconds!

When in column mode, sometimes referred to as "block mode", UltraEdit will highlight text based on the column position of the first character you select to the column of the last character you select. Text selected in column mode does not automatically include all text between the start and end position, but does include all text in the columns between the first and last character you select.

When column mode is enabled, additional features in the column menu are enabled as well. In the next few paragraphs, we'll take a look at some of those features.

Simple editing in column mode

To enable column mode, press Alt + C, or click Column mode in the Edit tab.

What happens if you select multiple columns and then drag one of the selected column boundaries?

You can configure a custom font for column mode so that it's obvious when the editor is in column mode. To do this, go to View » Fonts » Set hex / column mode font. For this tutorial we've chosen a bold version of our standard font.

What happens if you select multiple columns and then drag one of the selected column boundaries?

Column mode is useful for many things; even simple file editing is faster with column mode. In the sample Python script shown below, we have a section of code that needs to be commented out of the file. Instead of manually typing in the line comment char "#", you can hold the caret in position on the first line of code, then drag downward to the last line to be commented out. You now have a multiline 0-width caret position.

What happens if you select multiple columns and then drag one of the selected column boundaries?

Once the caret is positioned correctly, you can type the string, and the entire block of code will be commented out of the document.

What happens if you select multiple columns and then drag one of the selected column boundaries?

You can also use column mode to manually prepend or append sets of data spanning a column. In the following sample data, we would like to add a character to the beginning of each value after the "=" character. The added character will be the same for all values. As before, click and drag to create a "multiline caret" to insert the new character.

What happens if you select multiple columns and then drag one of the selected column boundaries?
What happens if you select multiple columns and then drag one of the selected column boundaries?

You can prepend an entire column of data, with the same character, by simply typing.

Insert / fill columns

The "Insert / fill columns" command in the "Column / block" group of the Edit tab allows you to enter a text string into a specific column in your data. If a column is selected, the string will be inserted into every selected line. However if nothing is selected, the string will be inserted into all lines in the file. If there is no text data at the specified column on a row within the file, spaces will be added to pad the row, thereby allowing the text to be inserted in the correct position.

In the below sample data, we need to add a new field to each row of SQL data. This can be done using the manual methods described above, but it would be much easier and faster with the "Insert / fill columns" command.

What happens if you select multiple columns and then drag one of the selected column boundaries?

Position the cursor in the appropriate placement of where you need to insert the data, and then select the "Insert / fill columns" icon in the Edit tab.

What happens if you select multiple columns and then drag one of the selected column boundaries?

You are then prompted for the string to insert.

What happens if you select multiple columns and then drag one of the selected column boundaries?

Type this in, and then press OK.

What happens if you select multiple columns and then drag one of the selected column boundaries?

As shown in the above screenshot, UltraEdit inserts the string in the caret-specific position on every line. If a selection had been made, the string would have been inserted into only every selected line.

Insert number

Another useful feature of column mode is the "Insert number" feature. This is very helpful when you need to numerically order a list of data. You can use this feature by positioning your caret into the top row of the column where you need to add numbers. You can then click the "Insert number" in the Edit tab.

If any text is highlighted at the invocation of this command, the highlighted text will be replaced by the inserted line numbers. The spacing required for the line numbers is calculated automatically based on the number of lines that will have a number inserted, the initial value and the increment.

What happens if you select multiple columns and then drag one of the selected column boundaries?

The ensuing dialog prompts you for specifications for numbering.

What happens if you select multiple columns and then drag one of the selected column boundaries?

First number: The digit(s) you enter here will be the first number of the number string that is inserted. So, if you entered "10" instead of "1", the number sequence would begin "10, 11, 12..." etc.

Increment: The digit(s) you enter here determines the increment of the count. For instance, if you enter "2" here, while your "First Number" is still specified as "10", the number sequence would begin "10, 12, 14..." etc.

Leading zeros: This option will prepend each number with the appropriate amount of zeros to pad the field to the same width (in characters) as the maximum number. For instance, if you begin a count with "1," and set the increment to "50" with "Leading Zeros" checked, your list would begin "001, 051, 101..."

For this tutorial, we only need numbering beginning with 1 and incrementing by 1, so we will leave the default options and press "OK".

What happens if you select multiple columns and then drag one of the selected column boundaries?

You now have a list of numbers on each line.

Sum selection

One way to save time and avoid error when adding column-specific data is to use "Sum selection" in the Edit tab. In our sample data below, we have some random sales figures that need to be totaled. Using the "Sum columns / selection" command we can total all the numbers that appear in a selected area.

What happens if you select multiple columns and then drag one of the selected column boundaries?

You will need to first make your selection, making sure to include ALL columns that include data to be summed. With your selection still active, click the "Sum selection" command in the Edit tab (shown above). The sum is calculated and then displayed in the "Sum Selected Text" dialog box.

What happens if you select multiple columns and then drag one of the selected column boundaries?

The "Ignore character in number" allows you to specify any character that should be ignored in a number. By default, this is set to a comma. This allows you to get the sum of a column of numbers where, for example, "1000" is written as "1,000".

Other column mode features

There are several other column mode features in the "Column / block" group of the Edit tab which haven't been covered here.

Delete / cut columns

These commands allow you to either delete or cut a specified number of columns from each row. Selecting this will prompt you for a number of columns you would like to delete or cut. The delete or cut will begin at the current caret position and will span the number of columns you specify. If you enter a value of 0, only the selected column will be deleted or cut.

CSV convert » Convert to fixed width

This function allows you to convert a file from character delimited fields to fixed columns. This is particularly useful where column manipulation is required, but difficult because of different field widths for each row. This function allows you to specify separator characters and field widths. You are also given the option to "scan" the file for UltraEdit to automatically detect field widths.

CSV convert » Convert fixed-width to CSV

The opposite of "Convert to fixed width," this function allows you to convert a file from fixed field widths to character delimited fields.

Left / center / right justify

These functions allow you to justify a selected column of data, with the boundaries of the selection acting as the margins. Left-justifying a column of data will justify the data against the left of your selection, while right-justifying will do the opposite. Center-justifying the column of data will center the data within the selection.