Matthias Pitzl wrote:

I don't really know how to do this but im sure that there's a solution.
I have some file and i need to insert a number before each line and a
separator. The number is the line number. Is there any way in vim to do
this easily?

Hello!

There's a number of ways to go about doing this. In addition to those mentioned already, there's also visincr, available at http://vim.sourceforge.net/scripts/script.php?script_id=670. Its more often
used to help with getting a portion of a file incremented...


abc[0]= 1
abc[0]= 1
abc[0]= 1

and transforming it to

abc[0]= 1
abc[1]= 2
abc[2]= 3

but it certainly can also be used to do an entire file:
 :%s/^/1: /
 1G
 ctrl-v
 $
 :I

translated:  place "1: " at the beginning of every line in the file.
Goto the beginning of file.
Start visual-block mode.
Goto the end of file.
:I (which will appear as :'<,'>I) transform selected numbers to an incremented list.

Visincr can also generate incremented (or decremented) lists of dates, alphabetic (a b c d) enumerations, months, days, etc.

Regards,
Chip Campbell

Reply via email to