Including Line Numbers in Text

General questions about using TextPad

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

Post Reply
mhill
Posts: 13
Joined: Fri Jan 20, 2006 7:15 pm

Including Line Numbers in Text

Post by mhill »

Hi, folks.

I am a long-time (and happy) user of TextPad. I am using version 4.7.3, paid mode.

I am about to try something new, and am hoping it can be done with TextPad: I would like line numbers to be included in the text of a document. So far, I know Preferences can be set so that line numbers will print with a document. But can I also specify a setting such that line numbers actually become part of the document, so that they get copied over to, say, a Word document?

Here's exactly what I want to do:
I have written several "C" programs in the Microsoft Visual C++ programming environment. I would like to copy the source code for those programs into webpages:
1) Cntrl-A to select everything (within the programming environment);
2) Cntrl-C to copy text;
3) Cntrl-V to paste the text into TextPad;
4) Insert the additional HTML code to convert the document into an HTML page for posting on a website.

Step 4 is the one about which I am unsure; I would like the line numbers to show up in the final webpage so that specific lines of code may be discussed in tutorials or discussions about the program.

So . . . rather than manually type in each line number, can TextPad save me this step?

Sincerely,


Michael
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Replace

Code: Select all

^
with

Code: Select all

\i_
to insert numbers at the beginnings of lines (the _ should be a space character) (of course, Regular expression must be selected)

Or select the first column (or any other column that should be after the line numbers) either by using the Alt key or the block select mode, then use Edit - Fill block - With numbers, set the other options as you want, then klick ok.
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

MudGuard,

Thanks for this! I've wanted to do something like this for a long time and didn't think it could be done.

So the next question is: how would you do it so as to make the numbers align right on say three digits...e.g.:

001
010
100

Edit: With a space following the number.

001 text
010 text

Also using the block select > Fill Block method I don't seem to be able to get it to do anything but insert the numbers, even with 'leading zeros' checked. Any ideas?

Never mind! I see using block select mode you need to select the number of columns you want to allocate to the numbers. The problem remains as to how to insert a space after the numbers without a second operation.
Best Wishes!
Mike Olds
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

With fill block, if you want to have right aligned/leading zero numbers, you have to select as many columns as you wish your numbers to have.
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

Thanks MudGuard, I got that, but how to add space after in block select mode, if possible.

Alternatively, using regex, how to insert the zeros up front.
Best Wishes!
Mike Olds
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Do it in two steps. One step for the numbers, one step for the space (use Edit - Fill Block - With characters for that).
mo
Posts: 306
Joined: Tue Mar 11, 2003 1:40 am

Post by mo »

OK, Thanks.
Best Wishes!
Mike Olds
mhill
Posts: 13
Joined: Fri Jan 20, 2006 7:15 pm

Post by mhill »

Vielen Dank, "MudGuard".

Your first suggestion works, although it will need some tweaking as line numbers go from two- to three-digit numbers (I want the "C" source code to be left-aligned smoothly, so I will probably end up padding the line-numbering field--so that it has a constant 5-space width).

However, you lost me with the second option.
I see "Fill Block..." as a selection in the "Edit" menu, but it is greyed out.
If I go to the "Configure" menu, and select "Block Select Mode", then go back to the "Edit" menu, the "Fill Block..." option is still greyed out. What am I overlooking?

Regards,


Michael
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Wordwrap must be off for Fill block.

(and I don't know if Fill block is available if you use a non-monospaced font)
Post Reply