Tuesday, June 7, 2011

Re: paste and increment a number

On 06/07/2011 11:10 AM, David wrote:
> Like for most problems googling long enough is sufficient.
>
> There is a plugin to handle this: http://vim.sourceforge.net/scripts/script.php?script_id=670
>
> I guess Dr. Chip has made a plugin for each of my problems :-).
>
> Thanks
>
You could also use a macro for this. Something like (just type all the
commands):

iValue1<ESC>qqyyp<C-A>q48@q

iValue1<ESC> -> goes to insert mode and types Value1
qq -> starts recording macro in register q
yyp -> copy/paste the Value1 line
<C-A> -> increment the value (1 becomes 2, 2 -> 3 etc)
q -> stop recording the macro
48@q -> play macro q 48 times (since you will already have 2 lines)

Jeroen


--
website: http://budts.be/ - twitter: @teranex
___________________________________
Registered Linux User #482240 - GetFirefox.com - ubuntu.com

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: