20061024

vi Number Sequence Trick

I'm a vim user. Often times in my editing, I want to number some of the lines in a file from 1 to some ending number. It might be only a few lines, or it might be thousands. To save myself some carpal tunnel, I wrote one line of perl to do the job. This program will pass a block of lines in whatever file you are editing to a one line perl script which will number the lines starting with 1 and drop that text back into the editor:
:x,y!perl -ne'print "$.  $_";'
In this example, x is the starting line number and y is the ending line number. That's it!

1 comment:

Paul E said...

more dark voodoo ;-)