Thursday, June 17, 2010

Re: numbering lines in groups

On Jun 16, 10:06 pm, John Little <john.b.lit...@gmail.com> wrote:
> > Are there other ways to increment via a map?
>
> I didn't understand your problem, the map looks too hard to read, and
> has tricky side effect semantics,


Please explain what you mean by the "tricky side effect semantics" as
I am learning.


> and this leads to the suggestion
> that you use a couple of functions, say, (minimally tested):
>
> let lpb = 4 "lines per block (zero based)
> function! Renum()
>     let g:b = 1
>     let g:l = 0
>    '<,'>s/^/\=ResInc()/
> endfunction
> function! ResInc()
>     let result = printf('( %4d_%X_)', g:b, g:l)
>     if g:l < g:lpb
>         let g:l += 1
>     else
>         let g:l = 0
>         let g:b += 1
>     endif
>     return result
> endfunction
>
> vmap <F4> :<c-u>call Renum()<cr>

Thank you for the function based version.

--
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: