Are printed line numbers all or nothing?

General questions about using TextPad

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

Post Reply
greatrussian
Posts: 5
Joined: Fri Apr 21, 2006 3:42 pm

Are printed line numbers all or nothing?

Post by greatrussian »

I'd like to print a file with line numbers, but don't need every one. Is it posssible to set it to only print every 5th line number?
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

At this point, TextPad does not offer the functionality you are looking for. As you asked, yes, printed line numbering is an all or nothing thing. Sorry to dissapoint. Perhaps some other soul out there will have an alternative solution for you.
I choose to fight with a sack of angry cats.
Boris
Posts: 16
Joined: Mon Apr 24, 2006 1:46 pm
Location: UK

Are printed line numbers all or nothing?

Post by Boris »

First, add an extra blank line at the beginning of your program.
This will be "line 0", which can be removed afterwards.

Then Find and Replace the following:

Find : (^.*)\n(^.*)\n(^.*)\n(^.*)\n(^.*)\n
Replace : \i(0,5)######\1\n######\2\n######\3\n######\4\n######\5

Note: Use POSIX syntax

I put hashes to indicate blank spaces. Please replace them before running. They are there to give a nice indentation to the result. Change as needed.

After running this, delete "line 0".

This will work through the whole of the text, EXCEPT the last few (5) lines (depending on the line numbers).
You can correct that manually yourself.

I hope this solution is useful.
Maybe someone could refine it further for you.

Cheers,

Boris.
greatrussian
Posts: 5
Joined: Fri Apr 21, 2006 3:42 pm

Post by greatrussian »

Thanks, I changed the replace to

Code: Select all

######\1\n######\2\n######\3\n######\4\n\i(5,5)##\5
which eliminated having to add an extra line at the beginning. Unfortunately, the indentation lines up only when there are the line number is 4 digits long.
Boris
Posts: 16
Joined: Mon Apr 24, 2006 1:46 pm
Location: UK

Post by Boris »

Thanks, I changed the replace to

Code: Select all

######\1\n######\2\n######\3\n######\4\n\i(5,5)##\5
which eliminated having to add an extra line at the beginning.
Ah, of course. :-)
Unfortunately, the indentation lines up only when there are the line number is 4 digits long.
Yes, the indentation is a problem.
I initially tried with tabs (\t), but they have the same problem.

As someone said before, it would be nice to have the \i work with left-padded zeroes.
Post Reply