Page 1 of 1

Align text in a block

Posted: Fri Sep 30, 2005 9:39 pm
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.

Posted: Fri Sep 30, 2005 10:59 pm
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