TP offers a very useful regular expression facility to add line numbers in front of every line in a text file. I use this often.
Is there any way to have these numbers right justified with leading blanks? Why would this be useful you ask? Because you can number your lines, sort the text file by some criteria, remove/relocate lines that cluster together by your sort key, and then restore the remaining lines back to their original order by sorting on the line numbers. Using Block Mode, you can remove the line numbers and your text file is restored as it was minus the lines you removed.
For example, if you have up to 200 lines in a file, you have to manually put two spaces in front of the first 9 lines, then one space in front of lines 10 to 99 to have the line numbers right justified in column 3.
Right justifying line numbers
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- A bit iffy
- Posts: 15
- Joined: Thu Sep 16, 2004 1:15 pm
- Location: Brighton, England
I also need to do this all the time, but I've always used a spreadsheet up to now.
There's an easy TextPad solution, though: in the search-and-replace facility, put
for the "Replace With", and your lines will all begin with three-digit numbers (for up to 900 lines, obviously) as they start from 100.
There's an easy TextPad solution, though: in the search-and-replace facility, put
Code: Select all
\i(100)
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
As noone has yet mentioned Fill Block:
Select as many columns as you want your numbers to have (block-selection), starting with the column in front of which the numbers should appear.
Go to Menu Edit - Fill Blocks
Select "With Numbers",
"Align Right" for leading blanks or "Leading Zeros" for leading zeros.
Make sure you have "insert" selected, not "replace".
Select as many columns as you want your numbers to have (block-selection), starting with the column in front of which the numbers should appear.
Go to Menu Edit - Fill Blocks
Select "With Numbers",
"Align Right" for leading blanks or "Leading Zeros" for leading zeros.
Make sure you have "insert" selected, not "replace".
- A bit iffy
- Posts: 15
- Joined: Thu Sep 16, 2004 1:15 pm
- Location: Brighton, England
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm