Align text in a block

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
rslotpole
Posts: 7
Joined: Fri Sep 30, 2005 9:33 pm

Align text in a block

Post by rslotpole »

Hi,

I have an 80 column file. In Columns 10 through 20 I have numbers but some of them are aligned right and some of them are aligned left within the block marked 10 to 20. Is there a way to align all these numbers to the right within the block i.e. they all end in column 20?

Great product. Thanks for your help.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

It depends on exactly how the lines are constrained. If each one is exactly 80 characters long, and if the 11 columns 10 to 20 contain a digit sequence surrounded by spaces, then this should do the trick:
Find what: ^(.{9})( *)([0-9]+)( *)(.{60})$
Replace with: \1\2\4\3\5

[X] Regular expression
Note how the beginning-of-line anchor (^) and end-of-line anchor ($), together with the 9-character prefix and 60-character suffix, fix the position of the 11-character line number field.

This assumes you are using POSIX regular expression syntax:
Configuration | Preferences | Editor

[X] Use POSIX regular expression syntax
Post Reply