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.
Align text in a block
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
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:
This assumes you are using POSIX regular expression syntax:
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.Find what: ^(.{9})( *)([0-9]+)( *)(.{60})$
Replace with: \1\2\4\3\5
[X] Regular expression
This assumes you are using POSIX regular expression syntax:
Configuration | Preferences | Editor
[X] Use POSIX regular expression syntax