Right justifying line numbers
Posted: Mon Jul 18, 2005 1:25 am
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.
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.