Topic: inserting line numbers (1 of 8), Read 21 times
Conf: Basic editing, Block operations
From: Harald Hahn
Date: Wednesday, February 15, 2006 04:47 AM

Hi,
is there an easy way to add line numbers at the beginning of each line in a text file?
I want to select a couple of lines ( including the numbers) and paste them to another application.

regards
Harald

 


Topic: inserting line numbers (2 of 8), Read 22 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Wednesday, February 15, 2006 06:58 AM

On 2/15/2006 4:47:45 AM, Harald Hahn wrote:
>Hi,
>is there an easy way to add line numbers at the beginning
>of each line in a text file? I want to select a couple of
>lines ( including the numbers) and paste them to another
>application.

In VEDIT's macro directory there is the macro Ins-Num.vdm which does that.

Place the cursor in your file at the first line to be numbered and execute the macro via menu {Misc, Load/exec macro}.

Christian

 


Topic: Re: inserting line numbers (3 of 8), Read 22 times
Conf: Basic editing, Block operations
From: Fritz Heberlein
Date: Wednesday, February 15, 2006 07:32 AM


>is there an easy way to add line numbers at the beginning of each line in a text file?
>I want to select a couple of lines ( including the numbers) and paste them to another application.
>
>
Have a look into the Macro Language Manual p. 60, where two methods for
doing that are discussed.

Fritz

 


Topic: inserting line numbers (4 of 8), Read 18 times
Conf: Basic editing, Block operations
From: Harald Hahn
Date: Wednesday, February 15, 2006 08:57 AM

Hi all,

thanks for your help !

As ususal it's not a question if it's possible within vedit it is only how it is possible.

Best regards
Harald

 


Topic: Re: inserting line numbers (5 of 8), Read 17 times
Conf: Basic editing, Block operations
From: Ted Green
Date: Wednesday, February 15, 2006 10:50 AM

At 04:48 AM 2/15/2006, you wrote:
>is there an easy way to add line numbers at the beginning of each line in a text file?
>I want to select a couple of lines ( including the numbers) and paste them to another application.

The supplied key-mac.lib has this macro:

**********
Line Numbering.
**********

Adds BASIC-like line number to the beginning of each line. First line number
is "100", next is "110" and so on. The cursor position is saved.

[VISUAL EXIT]
Save_Pos() #103=100 Begin_Of_File() Num_Ins(#103,NOCR) Ins_Char(' ')
while (! At_EOF) { #103+=10 Line(1,ERRBREAK) Num_Ins(#103,NOCR)
Ins_Char(' ') } Restore_Pos()

Modify it to your needs.

If someone wants to write a macro with a dialog box which prompts for the starting number, increment, etc., I will be glad to add it to {MISC, More macros}.

Ted.

 


Topic: Re: inserting line numbers (6 of 8), Read 24 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Wednesday, February 15, 2006 03:31 PM

On Wed, 15 Feb 2006 10:50:00 -0500, Ted Green wrote:

>If someone wants to write a macro with a dialog box which prompts
>for the starting number, increment, etc.,


I don't have the time for a complete macro now,
but here is a prototype for the dialog:


#90=2 // 1 = Block, 2 = whole file
#91=1 // 1 = Begin of File/Block, 2 = cursor pos
#92=1 // 1 = real line numbers, 2 = counter
#93=1 // 0 = no padding 1 = padding

// only of interest with padding enabled (#93=1)
#94=2 // 1 = with leading spaces 2 = with leading 0's
#95=1 // 0 = fixed width dependant on max number (5,10,14 digits)
// 1 = minimized fixed width

// only of interest with #92=2 (counter)
#97=1 // first number
#98=10 // increment
// divider
Reg_Set(92, "=") // a space usually is more appropriate,
// but invisible in the dialog ;-)

Num_Str(#97,90, LEFT) // convert numbers to strings for display
Num_Str(#98,91, LEFT)

#99=Dialog_Input_1(90,"`Line Numbering`,
`This macro inserts line numbers in front of lines of text.`,
`It will do it's work within `,
`() the highlighted block or the`, `.h() whole file`,
`beginning at`,
`() Begin_of_File/Block or`, `.h() current cursor position`,
`The numbers are:`,
`.g() the real line numbers or`, `.h() a counter with`,
`?? first number `,
`?? and increment`,
`The inserted numbers will be`,
`[] padded`,
`.t() with leading spaces or `, `.h() 0's to a fixed `,
`.t[] minimized width,`,
`?? using as divider between number and original line:`,
`[&Ok]`,`[&Cancel]`",
SET+APP+CENTER,0,0)



Christian

 


Topic: Re: inserting line numbers (7 of 8), Read 24 times, 1 File Attachment
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Sunday, February 19, 2006 04:17 PM

Now I redesigned the dialog a bit. It's still a prototype without function.

http://www.ziemski.net/vedit/macros/linenumbers.vdm

I attached a screenshot.

Opinions, ideas, suggestions?


Christian

 
LINENUMBER.JPG (25KB)

 


Topic: Re: inserting line numbers (8 of 8), Read 25 times
Conf: Basic editing, Block operations
From: Ted Green
Date: Sunday, February 19, 2006 05:44 PM

At 12:28 PM 2/19/2006, you wrote:
>Now I redesigned the dialog a bit. It's still a prototype without function.
>I attached a screenshot.
>Opinions, ideas, suggestions?

Wow. That is very fancy with many options. :-))

Ted.