Getting Vim to print increasing numbers
One of the many things I was yet to learn how to do with Vim was to generate simple increasing sequences, which could be used if I had to do something like:
From:
hello x y z
To:
hello1 x y z
hello2 x y z
...
hellon x y z
Simple copy-paste would give me n identical hello x y z lines. Then I'd have to manually enter the subscripts. So, I decided to write Vim commands that would let me print numbers from 1 too 100 in my document. The commands are as follows:
:let x=1
:map
:let i=1
:while i<=100
: execute "normal " . "\<F8>"
: let i=i+1
:endwhile
The first two lines let me get the next number after the current cursor position when I press F8. The last four give an effect of 100 presses of F8.
Should work with Vim 6.3 and above.
Refs: http://vimdoc.sourceforge.net/htmldoc/usr_41.html
No comments:
Post a Comment